Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search

Commerce API POST Endpoints returning 401 Unauthorized


JackC

Recommended Posts

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 post
  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...