Integrations and APIs for Service

Get Involved. Join the Conversation.


    Michael Locurcio
    Create Incident using Email as LookUp
    Topic posted January 28, 2019 by Michael LocurcioSilver Trophy: 7,500+ Points, tagged REST 
    60 Views, 2 Comments
    Create Incident using Email as LookUp

    I am trying to create an incident from an external system. I only want to make 1 API call. How can I do it without looking up a contact, just sending an email address. I know that the email may match more then 1 contact, and I am not picky about which contact it get associated with, I prefer the most recent, but again, not critical.

    Code Snippet:



    • Robert Surujbhan

      With the standard REST API, setting or changing the primaryContact on an Incident requires that you use the ID or lookupName, and lookupName on Contacts is defined as the First + Last Name ("michael something").  You probably saw this in the error message you saw being returned!  Not ideal, but can you use First + Last Name with your integration instead?  That would work. 

      Otherwise, with the REST API, you'd have to do another call to query for the contact ID using email address (/contacts/?q=emails.address='' is one way).

      If you really need to do this in one call, the alternative would be to build your own service using PHP and host a custom script on the site to create your own endpoint (accessible as a CP Controller in /cc or in the /interface.cfg/php/custom directory via File Manager).

    • Vlad

      Robert is right, you can't do 1 API call through REST or SOAP and you should use a PHP script instead. You would pass the email address and other details as either GET or POST parameters. You can fetch the contact via email address when you create the incident like this:

      $incident->PrimaryContact = RNCPHP\Contact::first("Email.Address = ''");