Hi!
I am building an App in R to generate leads based on user input that also queries a series of other APIs to populate the auto-populate fields. As part of the workflow, I first have to create an organisation which I’ve been able to successfully do using the following code:
#Creating Body
body_list <-
list(
name = 'org-test-final',
owner_id = '14069249',
address = 'test',
'e55ececa028500071612988156f8019db00dc838' = 'test',
'7fd7ef095fd39f3ce00588828084fc2a8dbb3b36' = 'test',
'ed20dd4374769b330f08ab10f30569d0fe8d93f4' = 'test'
)
#Creating URL
url <- paste0('https://MY_COMPANY.pipedrive.com/api/v1/organizations?api_token=', AUTH_TOKEN)
#Posting
org_post <- httr::POST(url, body = body_list)
#Checking status code
org_post[['status_code']]
The above yields the status code 201 (Success) and I am able to see the organisation appear on the web client. Next, I attempt to create a lead using the organisation ID from the newly created organisation:
#Creating Body
body_list <-
list(
title = 'lead-test',
organization_id = 2914
)
#Creating URL
url <- paste0('https://MY_COMPANY.pipedrive.com/v1/leads?api_token=', AUTH_TOKEN)
#Posting
lead_post <- POST(url, body_list)
#Checking status code
lead_post[['status_code']]
When doing this, I am faced with the status code 400 (Bad Request). I am unsure what I am doing wrong as I am following the same structure as how I successfully created the organization.