Solved

Error Not Found when post inventory_levels

Kent-Laustsen
Tourist
6 1 2

If I use GET https://mcs-nordic-denmark.myshopify.com/admin/api/2023-01/inventory_levels.json?inventory_item_ids=...

X-Request-ID: 44b8155d-31a0-4f21-968f-17a5edd4dc10

 

It works fine and I get:

{
    "inventory_levels": [
        {
            "inventory_item_id"45824964722915,
            "location_id"71439712483,
            "available"0,
            "updated_at""2023-02-22T11:26:46+01:00",
            "admin_graphql_api_id""gid://shopify/InventoryLevel/107749966051?inventory_item_id=45824964722915"
        }
    ]
}
 
X-Request-ID: e3085e62-f3d8-4df9-b043-7b6e4fe27cea
 
I get an error:
{
    "errors""Not Found"
}
 
What is wrong?
Accepted Solution (1)
Kent-Laustsen
Tourist
6 1 2

This is an accepted solution.

I finally found a solution, it turns out, that our customer created the shop using this url:

mcs-nordic.myshopify.com 

 

But later they added another: mcs-nordic-denmark.myshopify.com

 

The last url redirected to the first url. This works for GET, but failed if using POST.

 

My code works after changing to the first url:

POST: 

https://mcs-nordic.myshopify.com/admin/api/2022-04/inventory_levels/set.json?location_id=71439712483...

View solution in original post

Replies 8 (8)

garyrgilbert
Shopify Partner
397 40 165

Hi Kent,

 

Please refer to the documentation on how to set the inventory level.

 

https://shopify.dev/docs/api/admin-rest/2023-01/resources/inventorylevel#post-inventory-levels-set

 

It give a very specific example of what the post body should look like.

 

e.g.

{
    "location_id": 655441491, 
    "inventory_item_id": 808950810, 
    "available": 42
}

 

I believe its expecting json in the post body and not URL parameters.

 

Cheers,

 

Gary

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Kent-Laustsen
Tourist
6 1 2

Hi, Gary

 

I have tried with body in the Post, but it gives the same error.

{
    "location_id"71439712483
    "inventory_item_id"45824964722915
    "available"42
}
X-Request-ID: 9c40855c-2768-4fb7-b7bc-bae51b56ab47
 
I forgot to mention that our customer have another shop where Post works, so it might be a setting in the shop setup?
garyrgilbert
Shopify Partner
397 40 165

which scopes do you have for the shop where its not working?

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Kent-Laustsen
Tourist
6 1 2

I do not know, it is our customer who has made the setup of the shop.

Kent-Laustsen
Tourist
6 1 2

Our Customer writes that we should be allowed to edit all data.

garyrgilbert
Shopify Partner
397 40 165

Hi Kent,

 

make a get request to 

https://{myshopifydomain}/admin/oauth/access_scopes.json with the access token for the shop and that will give you a list of all the assigned scopes.
 
You should have the access scopes read/write_inventory if not thats the problem if you do then we need to dig deeper
 
Cheers,
 
Gary
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Kent-Laustsen
Tourist
6 1 2

Hi Gary,

 

I get this, so I guess that it is not the problem.

 

{
"handle": "write_inventory"
},
{
"handle": "read_inventory"
},

Kent-Laustsen
Tourist
6 1 2

This is an accepted solution.

I finally found a solution, it turns out, that our customer created the shop using this url:

mcs-nordic.myshopify.com 

 

But later they added another: mcs-nordic-denmark.myshopify.com

 

The last url redirected to the first url. This works for GET, but failed if using POST.

 

My code works after changing to the first url:

POST: 

https://mcs-nordic.myshopify.com/admin/api/2022-04/inventory_levels/set.json?location_id=71439712483...