Re: Inventory Item Id "expected float to be a id" issue in REST API call

Inventory Item Id "expected float to be a id" issue in REST API call

Junius
Shopify Partner
1 0 0

Hi there,

I'm fundamentally new to Shopify and working on an integration project using Azure Logic App.  One of the requirements is to set the available inventory quantity in Shopify using this API endpoint (myShopify.com/admin/api/2023-04/inventory_levels/set.json)I test the API endpoint using Postman and it perfectly works. 

The problem that I'm getting is in the Logic App, when I sent the request for the below input,

{
    "uri": "https://myShopify.com/admin/api/2023-01/inventory_levels/set.json",
    "method": "POST",
    "headers": {
        "Accept": "*/*",
        "Content-Type": "application/json",
        "X-Shopify-Access-Token": "xxxxxxxxxxxxxxxxx"
    },
    "body": {
        "available": 89,
        "inventory_item_id": 40978570519510,
        "location_id": 70811973482
    }
}
As you can see in the above payload, the body object has the inventory_item_id field with the value of 40978570519510 which is a double data type. The output throws an error which says below

 

"body": {
        "errors": {
            "inventory_item_id": "expected Float to be a id"
        }
    }

I don't really understand the problem.  I did googled it but could not find any similar issues encountered in Shopify. 

 

Has anyone encountered this before? any help is greatly appreciated.

 

Regards,

Junius

Reply 1 (1)

TravisImagine
Shopify Partner
16 0 2

Hello,

 

I think the problem is that you need to specific the whole ID as opposed to just the number. Try this:

 

{
    "uri": "https://myShopify.com/admin/api/2023-01/inventory_levels/set.json",
    "method": "POST",
    "headers": {
        "Accept": "*/*",
        "Content-Type": "application/json",
        "X-Shopify-Access-Token": "xxxxxxxxxxxxxxxxx"
    },
    "body": {
        "available": 89,
        "inventory_item_id": "gid://shopify/InventoryItem/40978570519510",
        "location_id": "gid://shopify/Location/70811973482"
    }
}