Reputation: 39
I am getting the error 'Exception: Request failed for https://api.pipedrive.com returned code 404. Truncated server response: {"status":false,"error":"Unknown method ."} (use muteHttpExceptions option to examine full response)' when attempting a put/post request to a Pipedrive deal. (Date Field) Below is the function producing the error. I am pretty sure this is something obvious but have not been able to determine the cause on my own. Any help would be appreciated.
function Update_pipedrive_Date(dealid, field_name){
var todays_date = Utilities.formatDate(new Date(), "GMT-5", "yyyy-MM-dd"); // "yyyy-MM-dd'T'HH:mm:ss'Z'"
var url = 'https://api.pipedrive.com/v1/deals/' + dealid + '?api_token='+oys_api_key
var data = {field_name: todays_date};
var options = {
'method': 'post',
'contentType': 'application/json',
'payload': JSON.stringify(data)
};
var response = UrlFetchApp.fetch(url, options);
return response
}
def update_field(this_dealid, fieldid):
tday = now.strftime("%Y-%m-%d")
headers = {'content-type': 'application/json'}
updates = {fieldid: tday}
resp = requests.put(
'https://api.pipedrive.com/v1/deals/' + str(
this_dealid) + '?api_token=' + api_key,
data=json.dumps(updates), headers=headers)
return resp
Upvotes: 0
Views: 347
Reputation: 201533
I believe your goal is as follows.
{field_name: todays_date}
, the key is always "field_name".When these points are reflected in your script, how about the following modification?
var field_name = "###"; // Please set your field_name.
var dealid = "###"; // Please set your dealid.
var oys_api_key = "###"; // Please set your oys_api_key.
var todays_date = Utilities.formatDate(new Date(), "GMT-5", "yyyy-MM-dd");
var url = 'https://api.pipedrive.com/v1/deals/' + dealid + '?api_token=' + oys_api_key;
var data = { [field_name]: todays_date };
var options = {
'method': 'put',
'contentType': 'application/json',
'payload': JSON.stringify(data)
};
var response = UrlFetchApp.fetch(url, options);
field_name
, dealid
, oys_api_key
again. Even when these variables are the valid values, when an error occurs, I'm worried that the URL might not be able to be accessed from the Google side.Upvotes: 1