2017-05-02 44 views
1

我一直在阅读周围的地方试图进入API的东西一段时间(承认几乎所有的东西都超出了我),发现this后,我可以链接我们的Pipedrive到Google表格与但是,当我尝试使用以数字开头的自定义字段API密钥时,它似乎绊倒了?从Google表格中的Pipedrive API导入数据 - 自定义字段?

即似乎(从下排第七)绊倒data.132的推...

任何线索/指针将不胜感激!

// 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; 
 
}

回答

1

Pipedrive工程师在这里。我认为你有JavaScript对象属性引用问题 - 它不能以数字开头。尝试:

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

+0

令人惊叹。非常感谢!我虽然一定是非常相似的东西,但却无法得到它。 – LMUF

相关问题