kittu
kittu

Reputation: 7018

Issue updating google contacts from javascript

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

Upvotes: 0

Views: 60

Answers (1)

QuasiFigures
QuasiFigures

Reputation: 67

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",
  ...
})
...

Upvotes: 2

Related Questions