Updating Inventory

SoloVueTest_Adm
Shopify Partner
12 0 0

I can get product data. I can get inventory data.  I can not update inventory data.  This is the response I get from PostMan: 

 

 
I don't understand what I am missing.  Please help.
0 Likes
aveshopstech
Excursionist
23 0 8

Hi @SoloVueTest_Adm, Without more info I can't be sure, but have you verified that you have the appropriate access scopes configured? Specifically, to update inventory you'd need the `write_inventory` scope.

0 Likes
SoloVueTest_Adm
Shopify Partner
12 0 0

Yes, I have write_inventory scope.  Here is the detailed log of the request.  Does this make any sense....

 


---- Sending ----
POST /admin/api/2020-04/inventory_levels/adjust.json HTTP/1.1
Host: david-christophers-inc-co.myshopify.com
Accept: application/json
Accept-Encoding: gzip
Content-Type: application/json
Content-Length: 88
Authorization: Basic MTU4MzdiMzE1NWJiMTI1NDdiMDM5M2EyYTYyMTk0OGQ6c2hwcGFfZDAxMzNiN2JmNGU5OGZlNjlmM2UwOTQxZDFkMDI1NTg=

{"location_id":28509208676,"inventory_item_id":26090581327972,"available_adjustment":56}
---- Received ----
HTTP/1.1 422 Unprocessable Entity
Date: Tue, 02 Mar 2021 04:14:44 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
X-Sorting-Hat-PodId: 112
X-Sorting-Hat-ShopId: 11762237540
Referrer-Policy: origin-when-cross-origin
X-Frame-Options: DENY
X-ShopId: 11762237540
X-ShardId: 112
X-Stats-UserId:
X-Stats-ApiClientId: 4549357
X-Stats-ApiPermissionId: 208620716145
X-Shopify-API-Terms: By accessing or using the Shopify API you agree to the Shopify API License and Terms of Use at https://www.shopify.com/legal/api-terms
HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT: 1/40
X-Shopify-Shop-Api-Call-Limit: 1/40
X-Shopify-API-Version: 2020-04
Strict-Transport-Security: max-age=7889238
X-Request-Id: 1ccab9c7-cdfd-4274-8777-52e553f3150e
X-Shopify-Stage: production
Content-Security-Policy: default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://* shopify-pos://*; block-all-mixed-content; child-src 'self' https://* shopify-pos://*; connect-src 'self' wss://* https://*; frame-ancestors 'none'; img-src 'self' data: blob: https:; script-src https://cdn.shopify.com https://cdn.shopifycdn.net https://checkout.shopifycs.com https://js-agent.newrelic.com https://bam.nr-data.net https://api.stripe.com https://mpsnare.iesnare.com https://appcenter.intuit.com https://www.paypal.com https://js.braintreegateway.com https://c.paypal.com https://maps.googleapis.com https://www.google-analytics.com https://v.shopify.com https://widget.intercom.io https://js.intercomcdn.com 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=adjust&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Finventory_levels&source%5Bsection%5D=admin_api&source%5Buuid%5D=1ccab9c7-cdfd-4274-8777-52e553f3150e
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 1; mode=block; report=/xss-report?source%5Baction%5D=adjust&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Finventory_levels&source%5Bsection%5D=admin_api&source%5Buuid%5D=1ccab9c7-cdfd-4274-8777-52e553f3150e
X-Dc: gcp-us-central1,gcp-us-central1
Set-Cookie: _y=f27db78c-50ea-43da-84eb-3e6b199473af; Expires=Wed, 02-Mar-22 04:14:44 GMT; Domain=david-christophers-inc-co.myshopify.com; Path=/; SameSite=Lax
Set-Cookie: _s=4619df2d-6b2d-4de0-bfbb-0fdb4ebe42b8; Expires=Tue, 02-Mar-21 04:44:44 GMT; Domain=david-christophers-inc-co.myshopify.com; Path=/; SameSite=Lax
Set-Cookie: _shopify_y=f27db78c-50ea-43da-84eb-3e6b199473af; Expires=Wed, 02-Mar-22 04:14:44 GMT; Domain=david-christophers-inc-co.myshopify.com; Path=/; SameSite=Lax
Set-Cookie: _shopify_s=4619df2d-6b2d-4de0-bfbb-0fdb4ebe42b8; Expires=Tue, 02-Mar-21 04:44:44 GMT; Domain=david-christophers-inc-co.myshopify.com; Path=/; SameSite=Lax
Set-Cookie: _shopify_fs=2021-03-02T04%3A14%3A44Z; Expires=Wed, 02-Mar-22 04:14:44 GMT; Domain=david-christophers-inc-co.myshopify.com; Path=/; SameSite=Lax
CF-Cache-Status: DYNAMIC
cf-request-id: 0892be4f0c000004df360bf000000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 6297ccc4d86f04df-LAX
alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400

 

0 Likes
aveshopstech
Excursionist
23 0 8

It looks like maybe that inventory item isn't being tracked. Check the REST API docs for InventoryLevel under examples for the POST inventory_levels/adjust endpoint. There's an example with a 422 response for "inventory levels for an inventory item that is untracked fails and returns an error". You may first need to set the `tracked` property on the InventoryItem to true. Hope that helps!

0 Likes