What's your biggest current challenge? Have your say in Community Polls along the right column.

POST call /inventory_levels/set.json returns oauth link

Solved

POST call /inventory_levels/set.json returns oauth link

BartJR
Tourist
4 1 2

Hi everyone,

 

I want to create a new application to update inventory levels manually. In order to do this I looked at https://shopify.dev/docs/admin-api/rest/reference/inventory/inventorylevel.

  • I created a private application and set permission for "Inventory" to read and write.
  • In Postman I created a new GET request, with Authorization Type "Basic Auth" and entered the key and password. In this case a get request on /admin/api/2021-04/inventory_levels.json?inventory_item_ids=42172356526249 
  • GET request got me this outcome (all good):

 

{
    "inventory_levels": [
        {
            "inventory_item_id": 42172356526249,
            "location_id": 61798908073,
            "available": 0,
            "updated_at": "2021-04-19T21:27:49+02:00",
            "admin_graphql_api_id": "gid://shopify/InventoryLevel/96112017577?inventory_item_id=42172356526249"
        }
    ]
}

 

  • Then I created a POST call using the same basic authorization with username and password to /admin/api/2021-04/inventory_levels/set.json in using a raw JSON body containing this:
{
"location_id": 61798908073,
"inventory_item_id": 42172356526249,
"available": 42
}
This returns HTTP 200, but instead of getting the correct JSON with the updated inventory, I get an oauth link however, that says "Continue".

I'm sure I'm doing something wrong here, but I can't figure it out. What am I missing here?

Accepted Solution (1)

BartJR
Tourist
4 1 2

This is an accepted solution.

Took a while, but figured it out. Removing the cookies did the trick!

View solution in original post

Replies 2 (2)

BartJR
Tourist
4 1 2

This is an accepted solution.

Took a while, but figured it out. Removing the cookies did the trick!

galago
Tourist
4 1 0

I have this exact issue with  2024-04/inventory_levels/set.json  

Getting a 200 OK - however in the JSON returned errors related to :


Clearing the cookies made no difference, does anyone have any ideas

My Admin API Config is set to having

galago_0-1713194338617.png