API call to get tasks Error
I try to get tasks from API:
My code is in Google Apps Script, here is the error I got:
Error: { "success":false, "error":"Required suites missing", "errorCode":402, "error_info":"Please check developers.pipedrive.com"}
Please help me to figure out the reason.
My options are:
{ "method": "get", "contentType": "application/json" }
Endpoint is:
https://api.pipedrive.com/v1/tasks?api_token=MY_API_TOKEN_HERE
I'm sure token is correct as other API endpoints work fine.
Answers
-
Thanks for the quick response,
Here is the code I use:
/** * @returns {Array<Object>} tasks */ function test_getPipeDriveTasks() { const apiEndpoint = "/v1/tasks"; const result = getPipedrive_(apiEndpoint); console.log(result); return result.data; } ///////////////////////////// API calling function ////////////////////////// /** * @typedef {Object} PipeDriveApiCommonParams * @prop {String} api_token * @prop {Number} limit * @prop {Number} start * @prop {String} [method] * @prop {Object} [payload] */ /** * @param {String} apiEndpoint * @param {PipeDriveApiCommonParams} [params] * * @returns {Object} data */ function getPipedrive_(apiEndpoint, params = {}) { const basicUrl = `https://api.pipedrive.com${apiEndpoint}`; params.api_token = 'PUT_YOUR_API_TOKEN_HERE'; const endpoint = getUrlParametrized_(params, basicUrl); const methhod = params.method || 'get'; const options = { 'method': methhod, 'contentType': 'application/json', 'muteHttpExceptions': true }; if (params.payload) { options.payload = params.payload; } try { const response = UrlFetchApp.fetch(endpoint, options); const statusCode = response.getResponseCode(); if (statusCode === 200) { var data = JSON.parse(response.getContentText()); return data; } else { console.log(`Error: ${response.getContentText()}`); } } catch (e) { console.log('Exception caught while fetching Pipedrive deals: ' + e.toString()); } } /** * @param {Object} obj * @param {String} url * * @returns {String} */ function getUrlParametrized_(obj, url) { let v, vals = []; for (let k in obj) { v = k + '=' + encodeURIComponent(obj[k]); vals.push(v); } const params = vals.join('&'); return url + '?' + params; }
In order to reproduce the error:
- Create a new script file, use script.new URL shortcut for that
- Copy my code
- Change token to yours:
PUT_YOUR_API_TOKEN_HERE
- Run the function
In my case I've got the error in logs:
Error: {"success":false,"error":"Required suites missing","errorCode":402,"error_info":"Please check developers.pipedrive.com"}
If you will not see the same error, this may be specific to my client's PipeDrive account,
1 -
Thanks for testing. If I'll have a response from support, I'll post a solution here.
1 -
The error text was not too helpful, but support helped a lot.
The reason was dummy: my client's Projects subscription has ended.
Special thanks to @inacyakup for very fast help here.
0 -
0