Below are the mandatory fields required to create an Inventory Adjustment via Zoho API:
- API being used:
- Token in Headers
- Method: POST
- Body:
{
"date": "2023-08-02",
"reason": "my reason",
"description": "Testing",
"adjustment_type": "quantity",
"line_items": [{
"item_id": 2954987000000641651, // ID from Zoho
"quantity_adjusted": -1
}]
}
When calling this API through Postman, it works fine with the following response from Zoho:
"code": 0,
"message": "Inventory Adjustment has been added",
"inventory_adjustment": {
// other details
}
ISSUE:
The problem arises when attempting to "Create Inventory Adjustment" from the Express server. There is a challenge in passing the item_id.
The API requires a Boolean data type for item_id, but due to JavaScript limitations, the provided ID: 2954987000000641651 which has 19 digits gets converted to a number that JavaScript can support (15 digits), resulting in a different ID like 2954987000000641500. This triggers an error response from Zoho:
{
code: 103003,
message: 'Non-inventory items(s) are involved in this transaction.'
}
This discrepancy occurs because specific item IDs get altered to fit within JavaScript's maximum supported value, causing non-existent IDs in the Zoho account.
Expected Behavior:
{
"date": "2023-08-02",
"reason": "my reason",
"description": "Testing",
"adjustment_type": "quantity",
"line_items": [{
"item_id": 2954987000000641651, // ID from Zoho
"quantity_adjusted": -1
}]
}
Actual Outcome:
{
"date": "2023-08-02",
"reason": "my reason",
"description": "Testing",
"adjustment_type": "quantity",
"line_items": [{
"item_id": 2954987000000641500, // ID from Zoho
"quantity_adjusted": -1
}]
}
An attempt was made using BigInt(2954987000000641651), but it resulted in a server error:
TypeError: Do not know how to serialize a BigInt
at JSON.stringify(<anonymous>)....
How can this issue be resolved?