Javascript Equivalent

I may be missing something here, but all the documentation I see only shows PHP code. Are there no JS equivalent examples for updating a Deal?

Here’s an example:

var update = {
"query": ("https://api.pipedrive.com/v1/deals/" + useData.deal.pdDeal.id + "?api_token=" + useData.api.pd),
"options": {
  'method' : 'put',
  'accept': 'application/json',
  'contentType': 'application/x-www-form-urlencoded',
  'payload': {
	'status': 'open',
	'title': useData.compared.deal.finalTitle,
	'stage_id': useData.parsed.stageId,
  }
}
};
var dealResponse = JSON.parse(UrlFetchApp.fetch(update.query, update.options).getContentText());
2 Likes

Thanks @paulieweb. Another question regarding deleting files. The documentation does not specify any parameters to pass other than headers, therefore it only returns data for the file. Here’s my setup in Zapier code:

var update = {
'url': ('https://' + inputData.company + '.pipedrive.com/v1/files/' + inputData.id + '?api_token=' + inputData.api_token),
'options': {
  'headers': {'Accept': 'application/json'}
  }
};

const res = await fetch(update.url, update.options);
const json = await res.json();
return json;

A ideas on what else should be passed here?

Figured it out. I was missing method > DELETE. Newbie at this.

1 Like

Don’t worry, we’re all newbies at one point :wink: