cancel
Showing results for 
Search instead for 
Did you mean: 

Incentive Management OData APIs (Kubernetes) Questions

Ron_Hagan
Product and Topic Expert
Product and Topic Expert
0 Kudos

I have an application I'm working on that connects to the SAP Incentive Management OData APIs (Kubernetes) API.  I'm bringing back the first 100 rows of the Incentive Management Pipelines.

In Postman, the first 2 PipelineRunSeq values are 20547673299878036 and 20547673299878035.

In my application, I have a TypeScript file that is supposed to retrieve the same 100 Pipelines.  The first 2 PipelineRunSeq values are 20547673299878036 and 20547673299878036.  The other values of the first item returned match the values of 20547673299878036 in Postman.  The other values of the second item match the values of 20547673299878035 in Postman.

The next 5 rows from the response in the application have 20547673299878030 as the PipelineRunSeq but the other values match the values in Postman for 20547673299878034, 20547673299878033, 20547673299878032, 20547673299878031 & 20547673299878030.

I'm stumped as to why the PipelineRunSeq is being returned in this way from within the TS script.

Any ideas and/or suggestions would be greatly appreciated.

Thanks in advance!

Ron

Accepted Solutions (0)

Answers (1)

Answers (1)

Ron_Hagan
Product and Topic Expert
Product and Topic Expert
0 Kudos

So I found out from one of the people who actually work on that API, that there seems to be an issue with the JSON.parse function for big numbers.  (Who knew?)

She suggested a code change and it works.  So instead of having this:

const data = await apiResponse.json();
const res= JSON.parse(data);

She told me to use this:

const data = await apiResponse.text();
const jsonWithQuotes = data.replace(/PipelineRunSeq\":\s*[^"0-9.]*([0-9.]+)/g, 'PipelineRunSeq\":"$1"');
const res = JSON.parse(jsonWithQuotes);
 
I'm going to do some research on JSON.parse() to see if there is any option to parse big numbers as text.  In any case, I'm good to go.