Guest Posted January 22, 2021 Share Posted January 22, 2021 I am trying to update product variants and adjust stock quantities for products using the commerce API endpoints as seen here and here. I am running into an issue where it is giving me a 401 unauthorized request although I have all of the required headers, as well as the correct body. I can make this POST request through Postman no problem but trying to make an identical request through javascript only returns 401 unauthorized. Simple example (using product variant endpoint): await axios.post(`${API_URL}/${productId}/variants/${variantId}`, { headers: { 'Authorization': 'Bearer ' + API_KEY, 'Content-Type': 'application/json', 'User-Agent': 'blahblahblah' }, body: body }).then(function (data) { console.log(data); }) .catch(function (error) { console.log(error); }); If anyone could provide guidance on why this is happening and how to fix that would be greatly appreciated! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment