Solved

Update product variant sku by rest admin api

SalvoP
New Member
4 0 0

Hi all,

 

I'm trying to update sku for products variant using admin rest api.

 

this is api address i'm using:

https://mydomain/admin/api/2023-04/variants/40609745469533.json

 

and this is payload i'm passing in body:

{
    "variant": {
        "id": 40609745469533,
        "sku": "AAAXXX"
    }
}

 

I would like change current sku value of this variant from "M65" to "AAAXXX".

 

Postman test gives me no error and response status 200 OK, but variant sku doesn't change.

 

May anyone help me?

 

Thanks in advance.

Accepted Solution (1)

Liam
Shopify Staff
2731 301 779

This is an accepted solution.

Hi SalvoP,

 

Could you try performing the same action but with a curl command rather than via Postman, to rule out that this is being caused by something on Postman's side? eg:

 

curl -X PUT 'https://mydomain/admin/api/2023-04/variants/40609745469533.json' \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: your_access_token' \
-d '{
  "variant": {
    "id": 40609745469533,
    "sku": "AAAXXX"
  }
}'

This command should send a PUT request to the Shopify API to update the SKU of the specified variant of the connected store, and if it works then it would be worth looking at how auth is set up on Postmans side.

 

Hope this helps,

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 6 (6)

Liam
Shopify Staff
2731 301 779

This is an accepted solution.

Hi SalvoP,

 

Could you try performing the same action but with a curl command rather than via Postman, to rule out that this is being caused by something on Postman's side? eg:

 

curl -X PUT 'https://mydomain/admin/api/2023-04/variants/40609745469533.json' \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: your_access_token' \
-d '{
  "variant": {
    "id": 40609745469533,
    "sku": "AAAXXX"
  }
}'

This command should send a PUT request to the Shopify API to update the SKU of the specified variant of the connected store, and if it works then it would be worth looking at how auth is set up on Postmans side.

 

Hope this helps,

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

SalvoP
New Member
4 0 0

Hi Liam,

 

Thank you so much for your answer.

 

Performing curl request works!

On postman, auth for get requests works fine. For curl request i've used same X-Shopify-Access-Token than postman.

So what can i chek for?

Liam
Shopify Staff
2731 301 779

Are you making a PUT request on Postman, rather than a GET request? 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

SalvoP
New Member
4 0 0

i've made a put request to update variant sku.

Liam
Shopify Staff
2731 301 779

Hi SalvoP,

 

If you're still experiencing issues you may need to contact Partner Support who can take a deeper look into this call and any logs we can see on our end.

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

SalvoP
New Member
4 0 0

Thank you Liam,

 

The issue is only related to Postman.

code in my .net application works fine.