Reputation: 13
I have been reading bits and bobs around the place to try and get into the API stuff for a while now (admittedly almost everything is beyond me), found this post which I was able to link our Pipedrive into Google Sheets with however it seems to stumble when I try to work with a custom field API key that starts with numbers?
i.e. seems to stumble on the push of data.132... (7th row from bottom)
Any clues/pointers would be greatly appreciated!
// Standard functions to call the spreadsheet sheet and activesheet
function GetPipedriveDeals() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getActiveSheet();
//the way the url is build next step is to iterate between the end because api only allows a fixed number of calls (100) this way i can slowly fill the sheet.
var url = "https://api.pipedrive.com/v1/deals:(org_name,title,owner_name,status,pipeline_id,value,a4f55810dfde1c6bead0709c5e0362a693e1a737,132c9a542e33bb3a2af984585eab85a0ee95b708)?start=";
var limit = "&limit=500";
var filter = "&filter_id=64";
var pipeline = 1; // put a pipeline id specific to your PipeDrive setup
var start = 0;
// var end = start+50;
var token = "&api_token=YOUR_API_TOKEN"
//call the api and fill dataAll with the jsonparse.
//then the information is set into the
//dataSet so that i can refill datall with new data.
var response = UrlFetchApp.fetch(url+start+limit+filter+token);
var dataAll = JSON.parse(response.getContentText());
var dataSet = dataAll;
//create array where the data should be put
var rows = [], data;
for (var i = 0; i < dataSet.data.length; i++) {
data = dataSet.data[i];
if(data.pipeline_id === pipeline){
rows.push([data.title, data.org_name, data.owner_name, data.status, data.pipeline_id, data.a4f55810dfde1c6bead0709c5e0362a693e1a737, data.value, data.132c9a542e33bb3a2af984585eab85a0ee95b708]);//your JSON entities here
}
}
Logger.log( JSON.stringify(rows,null,2) ); // Log transformed data
return rows;
}
Upvotes: 1
Views: 946
Reputation: 6155
Pipedrive engineer here. I think you have javascript object property referencing issue - it cannot start with numbers. Try:
rows.push([data.title, data.org_name, data.owner_name, data.status, data.pipeline_id, data['a4f55810dfde1c6bead0709c5e0362a693e1a737'], data.value, data['132c9a542e33bb3a2af984585eab85a0ee95b708']]);//your JSON entities here
Upvotes: 1