Product variant endpoint api

Hemlata
Tourist
11 0 0

On partner dashboard shows the API change error like " The inventoryQuantity, inventoryQuantityAdjustment, restock and other fields related to legacy inventory calls have been deprecated. The location_id is now required when creating fulfillment and refund requests" this, but I have changed all API version and checked parameter and changed. Now i am not getting, why is still showing this error to me. I have application in PHP.  Please help me. Thanks in advance

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 227

Maybe post some sample code. Most helpful would be a capture of the API request you are making, along with the API response. This would shed some light on what's taking place!

0 Likes
Hemlata
Tourist
11 0 0
POST /admin/api/2020-04/inventory_levels/set.json
{
  'location_id' => $locationId,
'inventory_item_id' => $inventory_item_id,
'available' => 0 }

my post parameter is as above given, and in other POST APIs I am not using inventory_quantity parameters.

inventory_quantity
READ-ONLY
"inventory_quantity": 10

An aggregate of inventory across all locations. To adjust inventory at a specific location, use the InventoryLevel resource.

old_inventory_quantity
DEPRECATED
"old_inventory_quantity": 5

This property is deprecated. Use the InventoryLevel resource instead.

inventory_quantity_adjustment
DEPRECATED
"inventory_quantity_adjustment": 5

This property is deprecated. Use the InventoryLevel resource instead.

as per this given info I am checking inventory level APIs

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 227

I would check your request's POST body, using something like Postman. That way you can see exactly what you are passing to the Shopify API endpoint. Here is a capture of a successful setting of inventory level I made. The request/response pair is below.

 

POST https://{my_shop}.myshopify.com/admin/inventory_levels/set.json HTTP/1.1
Content-Type: application/json
Authorization: Basic {my_access_creds}
User-Agent: PostmanRuntime/7.26.1
Accept: */*
Host: {my_shop}.myshopify.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 88

{
  "location_id": 203128,
  "inventory_item_id": 33193860300852,
  "available": 1
}
HTTP/1.1 200 OK
Date: Thu, 25 Jun 2020 14:15:40 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Set-Cookie: __cfduid=dda05321a5657bde0c725c4a6a8666f311593094539; expires=Sat, 25-Jul-20 14:15:39 GMT; path=/; domain=.myshopify.com; HttpOnly; SameSite=Lax
X-Sorting-Hat-PodId: 161
X-Sorting-Hat-ShopId: 3036253
Vary: Accept-Encoding
Referrer-Policy: origin-when-cross-origin
X-Frame-Options: DENY
X-ShopId: 3036253
X-ShardId: 161
X-Stats-UserId: 
X-Stats-ApiClientId: 309925
X-Stats-ApiPermissionId: 8304915
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: 2019-04
Strict-Transport-Security: max-age=7889238
X-Request-Id: 0bee6cd8-e4eb-42db-a8c1-0f2f2d7313a7
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=set&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Finventory_levels&source%5Bsection%5D=admin_api&source%5Buuid%5D=0bee6cd8-e4eb-42db-a8c1-0f2f2d7313a7
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=set&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Finventory_levels&source%5Bsection%5D=admin_api&source%5Buuid%5D=0bee6cd8-e4eb-42db-a8c1-0f2f2d7313a7
X-Dc: gcp-us-central1,gcp-us-central1
NEL: {"report_to":"network-errors","max_age":2592000,"failure_fraction":0.01,"success_fraction":0.0001}
Report-To: {"group":"network-errors","max_age":2592000,"endpoints":[{"url":"https://monorail-edge.shopifycloud.com/v1/reports/nel/20190325/shopify"}]}
CF-Cache-Status: DYNAMIC
cf-request-id: 038d6ea2c70000c50cb338b200000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 5a8f4d4adb64c50c-ORD
alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400
Content-Length: 226

{"inventory_level":{"inventory_item_id":33193860300852,"location_id":203128,"available":1,"updated_at":"2020-06-25T14:15:40Z","admin_graphql_api_id":"gid:\/\/shopify\/InventoryLevel\/4232978?inventory_item_id=33193860300852"}}

Once you have a capture of what your request is actually sending it should be clearer. The inventory_item_id and location_id have to correspond to valid values. And they need to be in numerical form (i.e. - not a quoted string).