Here is the require fields of Create the Inventory Adjustment through Zoho API:
- API that I'm using: https://www.zohoapis.com/inventory/v1/inventoryadjustments
- token in Headers
- Method: POST
- Body:
{
"date": "2023-08-02",
"reason": "my reason",
"description": "Testing",
"adjustment_type": "quantity",
"line_items": [{
"item_id": 2954987000000641651, // This id is coming from Zoho
"quantity_adjusted": -1
}]
}
When I try to hit this API from Postman it is working good and have this message from zoho:
"code": 0,
"message": "Inventory Adjustment has been added",
"inventory_adjustment": {
// other details
}
PROBLEM:
Now let's come to the my server when I try to "Create Inventory Adjustment" from my Express server. I have problem to pass item_id.
API require an bool data type for item_id but in JavaScript when I try to pass this ID: 2954987000000641651 it has 19 digits and JavaScript integer only support 15 digits. So it's convert every ID with like this 2954987000000641500 and I have this response from Zoho:
{
code: 103003,
message: 'Non-inventory items(s) are involved in this transaction.'
}
This is because When I try to adjust a specific item ID, it changes the id into different number that js maximum support. And that item is not exist in my zoho account. Like:
Expected:
{
"date": "2023-08-02",
"reason": "my reason",
"description": "Testing",
"adjustment_type": "quantity",
"line_items": [{
"item_id": 2954987000000641651, // This id is coming from Zoho
"quantity_adjusted": -1
}]
}
What actually happening:
{
"date": "2023-08-02",
"reason": "my reason",
"description": "Testing",
"adjustment_type": "quantity",
"line_items": [{
"item_id": 2954987000000641500, // This id is coming from Zoho
"quantity_adjusted": -1
}]
}
I also tried to use BigInt(2954987000000641651) but my server gives me error:
TypeError: Do not know how to serialize a BigInt
at JSON.stringify(<anonymous>)....
How can I solve this problem?