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

460
Views
Nodejs PUT/PATCH is not working with axios and request but same works from Postman

I am trying to make some modifications to my Rest API by making the PUT request using request package but it does not seem to work so. Although I am able to make the modifications to the same API using the same JSON body using the Postman. Also, I am not getting any errors so not understanding what's wrong.

Since request was not working, I tried axios even with that no response no error. Following is my sample code which is making request to my Rest API:

const request = require('request');
const axios = require('axios');
const https = require('https');

request(
{ 
    url: testIdUrl,
    method: 'PUT',
    agentOptions: {
    rejectUnauthorized: false
  },
  headers: [{
    'content-type': 'application/json',
    body: JSON.stringify(requestBody)
  }]
},
function(error, response, body) {
  if(error){
    console.log("SOMETHING WENT WRONG")
    console.log(error)
  }
  console.log("RESPONSE FROM TEST ID PUT")
})   

axios.put(testIdUrl, requestBody)
.then((res) => {
    console.log(`Status: ${res.status}`);
    console.log('Body: ', res.data);
}).catch((err) => {
    console.error(err);
}); 

Can someone please help me understand what's wrong with the code? Does my Rest API include all the tokens and information? When I use the same requestBody and URL then its works in POSTMAN.

about 4 years ago · Juan Pablo Isaza
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!