Updating name field in Javascript

Hi

I am having troubles having change name with the API endpoint for Persons.

First i found the person id matching email name that user user enters and then using the id to use in the put request as shown below didn’t work.

var update = {
“query”: (“https://api.pipedrive.com/v1/persons/” + id + “?api_token=” + apitoken),
“options”: {
‘method’ : ‘put’,
‘accept’: ‘application/json’,
‘contentType’: ‘application/x-www-form-urlencoded’,
‘payload’: {
‘name’: ‘Siva Bala’,
}
}
};
var nameResponse = JSON.parse(UrlFetchApp.fetch(update.query, update.options).getContentText());

When i do it from Hurl.it i dont get any error, but it doesnt change the name field when i request back the json again.

I am confused at this point and would like to know how to proceed.

Can you try with

‘contentType’: ‘application/json’
and
‘payload’: JSON.stringify({ ‘name’: ‘Siva Bala’ })

?

1 Like