Creating a Lead (PHP / Guzzle)

I am attempting to create a new lead using the API with Guzzle for PHP. I am able to pull a list of my leads via the API but when I attempt to create one, I am getting 'Client error: `POST https://api.insightly.com/v3.1/Leads` resulted in a `404 Not Found` response'. I am assuming that the contents of the post (Body) is not correct but I am using an array with the key of 'fieldValues' and the value of an json encoded array of values from the api example.

Is the key of the body fieldValues?

here is a sample of my code:

$lead = [
'SALUTATION' => 'Mr',
'FIRST_NAME' => 'Steve',
'LAST_NAME' => 'Smith',
'TITLE' => 'Potential Customer',
'OWNER_USER_ID' => 12345678,
'LEAD_SOURCE_ID' => 234567,
'LEAD_STATUS_ID' => 456789,
'ADDRESS_STATE' => 'Michigan',
'ADDRESS_POSTCODE' => '48312',
'RESPONSIBLE_USER_ID' => 1234567,
'LEAD_DESCRIPTION' => 'website',
];
$results = $this->client->request('POST',
'https://api.insightly.com/v3.1/Leads',
['fieldValues' => json_encode($lead)],[
'headers' => [
'Authorization' => 'Basic '.base64_encode('my cool
api key)
]
]);

Anything glaring that I am doing wrong? Thanks!
0

Comments

2 comments
  • Official comment

    Hi,

     

    I went ahead and created a ticket so that I conduct some testing for you. Please be on the lookout for any emails.

     

    Best,

    Comment actions Permalink
  • Thank you! Is LEAD_ID required, as indicated in the API Body Schema, and should it be 0?

    0
    Comment actions Permalink

Please sign in to leave a comment.