-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Amazon Apis sends campaignId as number/integer #975
Comments
Hey NishealJ, thank you for opening this issue. We are aware of this problem and have been in a discussion with Amazon Ads API support. We did not arrive at any solutions yet. The value is documented as a But the value is numerical in JSON that comes from the API. So I don't understand how a JSON parser in JS is supposed to handle it? {
"campaignId": 123456789123456789
} I think it is actually wrong to use the ID as a number, and should have been a string, but I didn't design the API 😁 Do you have any suggestions? |
Correct @moltar, now bigInt campaignIds are more frequent. Right now, I also don't see any solution but I would try to get a plain text response and then play with it. |
Yeah, pretty much.
That is what I am thinking. But there are other caveats though. I have tried using bigint stuff, but then it will stringify internally and can lead to other type issues later in the code. If JS will coerce it to string, and you send it back down the API pipe, the API may not accept the string version of the ID. Maybe we could use: https://www.npmjs.com/package/json-bigint |
The weirdest part is that Amazon's own UI uses these IDs too, and it is also using browser JSON.parse 🤷🏼 I really don't get it! |
@NishealJ Started a PR attempt, but ran into too many errors in the parser and have to shelve it for now. If you feel like picking it up, please do! |
We are currently working on the next version of this API where this ID will be modeled as a string. Would that solve this problem? |
@AdsAPIPM It certainly would. Thanks for jumping in with the discussion! Generally, I believe all IDs should be strings. My sort-a heuristic is like this: will we do calculations with it? If no, then it is a string. In other words, does it make sense to do ID1 + ID2? In 99% of cases the answer is no. So even if as a developer I decide to use ints or bigints, I'd stringify it, and document it as a "dumb string". |
Cool, I'll try to pull & help too. |
@AdsAPIPM yes that would help a lot |
I came through a problem where I can see clear disparency in data.
When I send the request from postman the data is different and when I send it from amazon-advertising-api-sdk the data is different.
The reason is amazon ads API send campaignId as a number https://advertising.amazon.com/API/docs/en-us/sponsored-products/2-0/openapi#/Campaigns/listCampaigns and javascript cannot support long numbers so it just rounds offs.
For example, when I hit the API through postman the campaign id is 123456789123456789 but when I hit from sdk it becomes 123456789123456780.
Any work around this? @moltar @nguyentoanit
The text was updated successfully, but these errors were encountered: