0

I am using unirest in nodejs to send a PUT request to update the contacts.

unirest.put(url)
    .header({
        'Authorization': 'Bearer '+result.profileData.split('?access_token=')[1],
        'If-Match': '*',
    })
    .send({"entry":{"phoneNumber":req.body.mobile}})
    .end(function (res1) {
        res.send(res1);
    });
}

I am getting response: Object {statusCode: 415, body: "Content-Type application/x-www-form-urlencoded is not a valid input type.", headers: Object, request: Object}

I am sending the data as .send({"entry":{"phoneNumber":req.body.mobile}}) and I am not sure this is the correct format?

I didn't find any documentation on this based on javascript. Help would be appreciated

1 Answer 1

2

It looks like you need to provide a Content type header. So add it to the object passed into the .headers method with a value of json/application

...
.headers({
  "Content-Type": "application/json",
  ...
})
...
Sign up to request clarification or add additional context in comments.

3 Comments

Its updating now but setting the contact number to empty
Whats your error message? Also, you can typically can find out the correct request body format from the API documentation of the API with which you are interacting. Or read the source code of the API if accessible.
API documentation is very bad

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.