Getting Status: "Not Acceptable" while trying to update a variant price form Rest API Admin Shopify in Airtable Scripts

Viewed 25

this is my first question here in SO, so thanks to any one that help me with this problem.

Basically im trying to update in a PUT request a variant price. I'm using Airtbale scripting to run a javascript, and on this script i fetch the info to call the api and make the update.

var raw = JSON.stringify({
  "variant": {
    "price": "1011",
    "compare_at_price": "1011"
  }
});

console.log(raw);

var myHeaders = new Headers();
myHeaders.append("X-Shopify-Access-Token", api_token);
myHeaders.append("Content-Type", "application/json");

const params = {
  method:'PUT',
  headers:myHeaders,
  body: raw,
};

const url = 
`https://tryp-mexico.myshopify.com/admin/admin/api/2022-04/variants/42242378334462.json`

const response = await fetch(url,params);

console.log(response);

When i try tu run this update on Postman, it works well. But here im getting:

{type: "basic", url: "https://tryp-mexico.myshopify.com/admin/admin/api/2022-04/variants/42242378334462.json", status: 406, statusText: "Not Acceptable", ok: false…}

¡Thanks a lot for your help!

1 Answers

Your URL has "admin" twice.

const url = 
`https://tryp-mexico.myshopify.com/admin/admin/api/2022-04/variants/42242378334462.json`

Are you using a variable for the Shop URI, that possibly already has /admin in it?

This is the correct URI format for variants:

https://tryp-mexico.myshopify.com/admin/api/2022-04/variants/42242378334462.json

Related