Hey everyone! I’m new here and could use some help. I’m trying to update a variant price using a PUT request through the Shopify Admin API. I’m working with Airtable Scripts and JavaScript.
The weird thing is, it works fine in Postman, but when I run it in Airtable, I get a ‘Not Acceptable’ error (status 406). Here’s a simplified version of my code:
const updateData = {
variant: {
price: '999',
compare_at_price: '999'
}
};
const headers = {
'X-Shopify-Access-Token': shopifyToken,
'Content-Type': 'application/json'
};
const requestOptions = {
method: 'PUT',
headers: headers,
body: JSON.stringify(updateData)
};
const apiUrl = `https://my-store.myshopify.com/admin/api/2022-04/variants/123456789.json`;
const result = await fetch(apiUrl, requestOptions);
console.log(result);
Any ideas on why this might be happening? Thanks in advance for any help!
yo, had similar probs with shopify api. make sure ur headers r good. try adding:
headers[‘Accept’] = ‘application/json’;
also check ur shopify token. sometimes it expires n u dont notice. if that dont work, log the full response:
const response = await result.json();
console.log(JSON.stringify(response, null, 2));
good luck!
I’ve dealt with this exact issue before when integrating Shopify with Airtable. One thing that’s not immediately obvious is that Airtable Scripts have some quirks when it comes to network requests.
First, try wrapping your fetch call in a try-catch block to get more detailed error information. Sometimes Airtable swallows the actual error message.
Also, make sure you’re not hitting any rate limits. Shopify can be pretty strict, especially if you’re making multiple API calls in quick succession. You might need to implement some basic throttling.
Lastly, double-check your API version. Shopify regularly updates their API, and if you’re using an outdated version, it can cause unexpected issues. Try updating to the latest stable version and see if that resolves the problem.
If none of that works, you might need to reach out to Airtable support. They can sometimes provide insights into platform-specific issues that aren’t immediately apparent.
I’ve encountered similar issues when working with the Shopify Admin API in different environments. The ‘Not Acceptable’ error often stems from a mismatch in the expected response format. In Airtable Scripts, try adding an ‘Accept’ header to explicitly request JSON:
headers[‘Accept’] = ‘application/json’;
Also, double-check that your shopifyToken is correctly set and hasn’t expired. Sometimes, environment variables don’t transfer seamlessly between platforms.
If that doesn’t resolve it, you might need to adjust how you’re handling the response. Instead of logging the result directly, try:
const response = await result.json();
console.log(JSON.stringify(response, null, 2));
This will give you more detailed error information to troubleshoot. Let us know if you need further assistance after trying these steps.