401 unauthorized error on admin api call – shopify
401 unauthorized error on admin api call – shopify
I am facing unauthorized 401 error on shopify. I am using access token in fetch. I have used multiple ways like axios/xhr but still the issue is there. I have already tested this api call on postman and it is working fine on postman but not on shopify. How do i fix this issue. Am i missing any parameter in api call ? Please guide
fetch('https://mystore.myshopify.com/admin/api/2023-10/graphql.json', {
method: 'POST',
mode: 'no-cors',
headers: {
'X-Shopify-Access-Token': accessToken,
},
body: JSON.stringify({"query": stagedUploadsQuery,"variables": stagedUploadsVariables})
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
console.log('Full response:', response);
}
return response.json();
})
.then(data => {
// Handle the data here
console.log('Staged Upload Query Result:', data);
})
.catch(error => {
// Handle errors here
console.error('Error during the fetch:', error);
});
Run code snippetExpand snippet
Turbo Multi-language Translator
Make the better internet purchasing globaly
Turbosify SEO Speed Booster
5.0 (7)•Free plan available
Get better conversions by improving store loading speed
Installed
Turbo Multi-language Chat - AI Customer service in one hand