CRM-2 Contacts API

From Opentaps Wiki
Revision as of 14:06, 11 April 2013 by Jwickers (talk | contribs)
Jump to navigationJump to search

Contacts API is used to create and retreive contacts.

The API calls follow the general RESTful pattern of CRM-2 API.

The base URL is http://crm-2-url/crm2/contact

GET: Get a List of Contacts

  • contactId
  • emailAddress
  • attribute Map

POST: Create a contact

  • firstName
  • lastName
  • companyName
  • emailsNumber (used to iterate the following parameter where N is an index number)
    • emailN (the email address)
    • emailPurposeN (can be one of : PRIMARY, OTHER, ORDER, BILLING_AR, PAYMENT_AR, SHIPMENT)
  • attribute Map (described as a series of attribute_${key}=${value} parameters)

The operation returns a JSON response with the created contact eg:

 {"result":{"resultValue":{"contactId":"5166b967e4b0f6e6cd09e653","firstName":"test","clientDomain":"mydomain.com","emails":[{"email":"test@example.com","purpose":"PRIMARY"}],"attributes":{"somekey":"somevalue"}}}}

PUT: Update a contact

  • firstName
  • lastName
  • companyName
  • emailsNumber (used to iterate the following parameter where N is an index number)
    • emailN (the email address)
    • emailPurposeN (can be one of : PRIMARY, OTHER, ORDER, BILLING_AR, PAYMENT_AR, SHIPMENT)
  • attribute Map (described as a series of attribute_${key}=${value} parameters)

Note that when updating:

  • the attributes are always overwritten so not gving any attribute will remove the existing ones
  • emails are only overwritten if at least one email is given or emailsNumber is set to 0 in which case the existing ones will be removed
  • firstName, lastName, companyName are only updated when given, they must be given and set to an empty value to be removed

The operation returns a JSON response with the new values of the updated contact eg:

 {"result":{"resultValue":{"contactId":"5166b967e4b0f6e6cd09e653","firstName":"test","clientDomain":"mydomain.com","emails":[{"email":"test@example.com","purpose":"PRIMARY"}],"attributes":{"somekey":"somevalue"}}}}

Import Contact API

A similar API is available to easily import contacts, it only allows POST operations but will create the contacts or update if one is found matching the given attributes.

The base URL is http://crm-2-url/crm2/contact-import

POST: Create or update Contact

  • firstName
  • lastName
  • companyName
  • emailsNumber (used to iterate the following parameter where N is an index number)
    • emailN (the email address)
    • emailPurposeN (can be one of : PRIMARY, OTHER, ORDER, BILLING_AR, PAYMENT_AR, SHIPMENT)
  • attribute Map (described as a series of attribute_${key}=${value} parameters)

Only the attributes given as attribute_XXX are used to find an existing contact for update, if they are not given and / or a contact matching those is not found the operation will create a new contact.

The operation returns a JSON response with the contact ID of the created or updated record, eg:

 { "contact": { "contactId": XXX } }

The attribute Map is described as a series of attribute_${key}=${value} parameters. For example, attribute_opentapsPartyId=12345 will become {opentapsPartyId:12345}