Jump to content


Photo

Lead creation via API

api leads

  • Please log in to reply
1 reply to this topic

#1 localista

localista

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 24 April 2014 - 04:12 PM

Hi,

 

I'm seeking to insert a lead record into zurmo from a remote web app registration process. I've unit tested a number of issues out of my script but when it comes to inserting I get an error.  I've searched and cannot find an answer and I feel as though I am very close to a solution. Any help would be appreciated!

 

Basically the system is stating that the lastname and state name and state order are missing (cannot be blank) but I copied this test data directly from the API Contact Insert wiki.

 

 

Here is the data array I'm using:

 

Array   (   [firstName] => Michael   [lastName] => Smith   [jobTitle] => President   [department] => Sales   [officePhone] => 653-235-7824   [mobilePhone] => 653-235-7821   [officeFax] => 653-235-7834   [description] => Some desc.   [companyName] => Michael Co   [website] => http://sample.com   [industry] => Array   (   [value] => Financial Services   )       [source] => Array   (   [value] => Outbound   )       [title] => Array   (   [value] => Dr.   )       [state] => Array   (   [id] => 5   )       [primaryEmail] => Array   (   [emailAddress] => a@example.com   [optOut] => 1   )       [modelRelations] => Array   (   [opportunities] => Array   (   [0] => Array   (   [action] => add   [modelId] => 3   )       )       )       )

 

Here is the call I'm uising:
 

$response = ApiRestHelper::createApiCall('http://xxxxxxxx.com/...act/api/create/' 'POST', $headers, array('data' => $data));

$response = json_decode($response, true);

 

Here is the error message:

 

Array   (   [status] => FAILURE   [data] =>   [message] => Model was not created.   [errors] => Array   (   [lastName] => Array   (   [0] => Last Name cannot be blank.   )       [state] => Array   (   [name] => Array   (   [0] => Name cannot be blank.   )       [order] => Array   (   [0] => Order cannot be blank.   )       )       )       )

 



#2 masteryoshi

masteryoshi

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 12 May 2014 - 09:24 AM

  1. Since you were asking about inserting a new lead you need to replace the createApiCall URL to this one:
    path_to_zurmo/app/index.php/leads/contact/api/create/
  2. I'm not sure why it gives an error for the lastName, might be because of (1)
  3. you should check that the state number corresponds with the status you want to give to the new lead.
    You can go into Zurmo and edit some entry, then inspect the dropdown with Chrome Dev-tools or whatever, and see what is the right state id for you.
    for example, I wanted the new lead to be set to status=New: 
    https://db.tt/V94Pa7kn
    (don't mind the weird letters, that's Hebrew)






Also tagged with one or more of these keywords: api, leads

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users