Add Activity - "location" ignored

Hello,
i try add Activity with “location” parameter via API. Every kinds of inputs are ignored and “location” returned in Activity is empty string.

The same “location” strings inserted to Activity via Pipedrive frontend are added correctly.

Addresses for example:
“Štúrova 1705/55, Praha”
“Opletalova 25, Praha”

Is it argument “location” in action “Add an Activity” (Pipedrive API v1 Reference) working correctly? It is activated?

Thanks, Adam

Hi Adam,
It seems to be working for both myself and another of our developers.

Postman
I used Postman to add an activity with the “Štúrova 1705/55, Praha” address as a location. This is the JSON array I sent:

{
    "deal_id": "12",
    "person_id": "17",
    "location": "Štúrova 1705/55, Praha",
    "subject": "Activity added from API with location",
    "type": "lunch"
}

It came back with a 201 response, and this showed up in my web app:

Code from our developer
A developer of ours tried the endpoint, and it worked for him as well. This is the code he used.
Please do replace the your_ api _token and your_company_domain sections with your own values.

<?php
// Content of addActivity.php
// Pipedrive API token
$api_token = 'your_api_token';
// Pipedrive company domain
$company_domain = 'your_company_domain';
// Information regarding the new Activity
$data = array(
    'subject' => 'Activity added from API with location',
    'type' => 'lunch',
    'location' => 'Opletalova 25, Praha'
);
// URL for adding an Activity
$url = 'https://' . $company_domain . '.pipedrive.com/api/v1/activities?api_token=' . $api_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
echo 'Sending request...' . PHP_EOL;
$output = curl_exec($ch);
curl_close($ch);
// Create an array from the data that is sent back from the API
// As the original content from server is in JSON format, you need to convert it to PHP array
$result = json_decode($output, true);
// Check if the data returned in the result is not empty
if (empty($result['data'])) {
    exit('Adding failed' . PHP_EOL);
}
// Check if the Activity's ID came back, if it did, print out success message
if (!empty($result['data']['id'])) {
    echo 'Activity was added successfully!' . PHP_EOL;
}

Would you be able to try again with either/both of these methods, and let me know whether it works for you? :slightly_smiling_face:

Hello Nicole, thanks for reply.

Here is short node.js script with package “pipedrive”.

const pipedrive = require("pipedrive");
pipedrive.Configuration.apiToken = ".....";

pipedrive.ActivitiesController.addAnActivity({
    subject: "Location test",
    location: "Opletalova 25, Praha",
    dealId: 1317
}).then(res => {
    console.log(`Success: ${res.success}`);
    console.log(`Location: ${res.data.location}`);
})

And output:

Success: true
Location: null

Activity is successfully created, but without location.

Snímek obrazovky 2021-06-03 v 17.52.58

I see now. It’s not problem of API but JavaScript library :frowning:

Hi Adam,

Thank you for pointing this out to us!

I’ve brought up the bug to the developers who are managing this library. They’ve now created an issue to work on this, and also informed me that they’re currently working on a new library.

Hello, Nicole, is there any progress, please? Thanks.

Hi Adam,

Apologies for the late reply. Unfortunately, we don’t have any updates just yet due to our resources being stretched really thin in the summer. :slightly_frowning_face:

Hey!

You are now able to use the location parameter since SDK version 12.

const pipedrive = require('pipedrive');
pipedrive.ApiClient.instance.authentications['api_key'].apiKey = 'YOUR_API_KEY';
const api = new pipedrive.ActivitiesApi();

(async () => {
    try {
        console.log(await api.addActivity({ location: "Štúrova 1705/55, Praha"}));
    } catch (e) {
        console.error(e);
    }
})()