Add a new activity - API - Google Scripts - My parameters are ignored

Hello!

I am trying to create an activity using pipedrive’s API with google scripts

every time i send a request it creates an activity but it doesn’t use any of my set parameters
this is my code:

var data = {
“done”:“1”,
“subject”:“Test Ping”,
“type”:“Call”,
“due_date”: due_date,
“due_time”:due_time,
“duration”:“01:00”
}

var request = {
“method”:“POST”,
“headers”:{“Content-Type”:“application/json”},
“data”: data
};
console.log({‘Atividade’:request});

var response = UrlFetchApp.fetch(url, request);

var Json = JSON.parse(response.getContentText());
console.log({‘Json’:Json});
}


This is Pipedrive JSON response printed :

{ success: true,
data:
{ id: 3599,
company_id: 6683270,
user_id: 9981052,
done: false,
type: ‘call’,
reference_type: null,
reference_id: null,
conference_meeting_client: null,
conference_meeting_url: null,
due_date: ‘2020-07-10’,
due_time: ‘’,
duration: ‘’,
busy_flag: null,
add_time: ‘2020-07-10 12:29:13’,
marked_as_done_time: ‘’,
last_notification_time: null,
last_notification_user_id: null,
notification_language_id: null,
subject: ‘Ligar’,
public_description: null,
calendar_sync_include_context: null,
location: null,
org_id: null,
person_id: null,
deal_id: null,
lead_id: null,
lead_title: ‘’,
active_flag: true,
update_time: ‘2020-07-10 12:29:13’,
update_user_id: null,
gcal_event_id: null,
google_calendar_id: null,
google_calendar_etag: null,
source_timezone: null,
rec_rule: null,
rec_rule_extension: null,
rec_master_activity_id: null,
conference_meeting_id: null,
note: null,
created_by_user_id: 9981052,
location_subpremise: null,
location_street_number: null,
location_route: null,
location_sublocality: null,
location_locality: null,
location_admin_area_level_1: null,
location_admin_area_level_2: null,
location_country: null,
location_postal_code: null,
location_formatted_address: null,
attendees: null,
participants: null,
series: null,
org_name: null,
person_name: null,
deal_title: null,
owner_name: ‘Lana’,
person_dropbox_bcc: null,
deal_dropbox_bcc: null,
assigned_to_user_id: 9981052,
file: null },
additional_data: { updates_story_id: null },
related_objects: { user: [Object] } } }"

I can’t get that right, can someone help me out?

Hi Caio,

Have you been able to get this work via the https://developers.pipedrive.com/docs/api/v1/ page?

Yes i could retrieve it with pipedrive APIs.

After long tries and errors i found out that pipedrive receive it with payload and I finally could archieve the same as the PHP with javascritp in google scripts following the example below:

var date = new Date();
var due_date = Utilities.formatDate(date,‘America/Sao_Paulo’,‘yyyy-MM-dd’);
var due_time = Utilities.formatDate(date,‘America/Sao_Paulo’,‘HH:mm’);
console.info({‘due_date’:due_date,‘due_time’:due_time});

var data = {
done:‘1’,
subject:‘Teste ping Atende Simples’,
duration:‘01:00’,
type:‘call’,
due_date:due_date,
due_time:due_time
};

var request = {
“method”:“POST”,
“headers”:{“Content-Type”:“application/json”},
“payload”: JSON.stringify(data),
};

You can mark this as Solved!

1 Like

Happy to hear you were able to figure it out on your own :+1: