Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
GET method gives success but PUT method gives 401 despite same credentials

The problem Overview

  • When getting products using a GET method everything works
  • when trying to update a product using PUT method I get 401 unauthorized
  • I use same credentials for both methods
  • The bearer token is global scope, I should be authorized to do anything to a given product

The code

GET

// javascript
const axiosOptions = {
  headers: {
    "Authorization": `Bearer ${token}`
  }
}

const onAllClick = async () => {
  const result = await axios.get(`https://api.printify.com/v1/shops/${shopId}/products.json?limit=30`, axiosOptions );
  const products = result.data.data; 
  console.log(products);
}

PUT

javascript
const axiosTagUpdateOptions = {
  headers: {
    "Authorization": `Bearer ${token}`
  },
  data: {
    title:"New product title"
  }
}


const onEditTagsClick = async (productID, tags) => {
  await axios.put(`https://api.printify.com/v1/shops/${shopId}/products/60e0a5c198be4c1296798c27.json`, axiosTagUpdateOptions)
  .catch(err => console.log(err));
}

Problem

The get function works perfectly fine. But whenever I try to modify a product using the put method, like the documentation says, I get a 401 unauthorized error. But I'm using the same token for both the get and the put method. The token is set to global scope (for testing purposes) so I should be able to edit and delete products at will.

I read through the API documentation and it looks like I got everything right. I have the bearer token as the header and in the body I included the value I want to modify. Obviously the request is going through, I just don't know why it keeps saying I'm unauthorized to edit the product. I would have liked to edit the product from the printify UI, but the UI won't let me add tags (which is really annoying)... So I'm forced to update via a put method.

I couldn't find any reason for why I am getting this error, can anyone help me?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

For put request you must pass data as a parameter and not in axiosOptions.

const onEditTagsClick = async (productID, tags) => {
  await axios.put(`https://api.printify.com/v1/shops/${shopId}/products/60e0a5c198be4c1296798c27.json`, data, axiosTagUpdateOptions)
  .catch(err => console.log(err));
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!