REST API Specification – Contacts

Note: In all API calls, replace the % and example values between the % signs with your own variable values.

Get Contact

Replace %id% with the id of the contact that you want to retrieve, %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Retrieve contact by id.
  • URL structure: http://crmme_url/index.php/contacts/contact/api/read/%id%
  • Method: GET
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters: None
  • PHP sample:
$authenticationData = login('super','super');
//Add code to check if user is logged successfully

$id = 1; // Change this with value of contact id

$headers = array(
    'Accept: application/json',
    'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
    'ZURMO_TOKEN: ' . $authenticationData['token'],
    'ZURMO_API_REQUEST_TYPE: REST',
);
$response = ApiRestHelper::createApiCall('http://crmme_url/index.php/contacts/contact/api/read/' . $id, 'GET', $headers);
// Decode json data
$response = json_decode($response, true);
if ($response['status'] == 'SUCCESS')
{
    $contact = $response['data'];
    //Do something with contact
}
else
{
    // Error, for example if we provided invalid contact id
    $errors = $response['errors'];
    // Do something with errors
}
  • Return:
    Data contains contact info.
{
  "status":"SUCCESS",
  "data":{
    "id":1,
    "createdDateTime":"2012-05-07 08:18:11",
    "modifiedDateTime":"2012-05-07 08:18:11",
    "createdByUser":{
      "id":1,
      "username":"super"
    },
    "modifiedByUser":{
      "id":1,
      "username":"super"
    },
    "owner":{
      "id":1,
      "username":"super"
    },
    "department":null,
    "firstName":"First",
    "jobTitle":null,
    "lastName":"Firstson",
    "mobilePhone":null,
    "officePhone":null,
    "officeFax":null,
    "primaryAddress":null,
    "primaryEmail":null,
    "title":null,
    "companyName":null,
    "description":null,
    "website":null,
    "account":null,
    "industry":null,
    "secondaryAddress":null,
    "secondaryEmail":null,
    "source":null,
    "state":{
      "id":5
    }
  },
  "message":null,
  "errors":null
}

Delete Contact

Replace %id% with the id of contact that you want to delete, %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Delete contact by id.
  • URL structure: http://crmme_url/index.php/contacts/contact/api/delete/%id%
  • Method: DELETE
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters: None
  • PHP sample:
$id = 1; // Change this value to contact id that you want to delete
$authenticationData = login('super','super');
//Add code to check if user is logged successfully

$headers = array(
    'Accept: application/json',
    'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
    'ZURMO_TOKEN: ' . $authenticationData['token'],
    'ZURMO_API_REQUEST_TYPE: REST',
);
$response = ApiRestHelper::createApiCall('http://crmme_url/index.php/contacts/contact/api/delete/' . $id, 'DELETE', $headers);
$response = json_decode($response, true);
if ($response['status'] == 'SUCCESS')
{
    // Inform user that contact is deleted
}
else
{
    // Error, for example if we provided invalid contact id
    $errors = $response['errors'];
    // Do something with errors
}
  • Return:
{
  "status":"SUCCESS",
  "data":null,
  "message":null,
  "errors":null
}

Create New Contact

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Create new contact
  • URL structure: http://crmme_url/index.php/contacts/contact/api/create/
  • Method: POST
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters:
$data = Array
(
    [firstName] => Michael
    [lastName] => Smith
    [jobTitle] => pre class="prettyprint linenums"sident
    [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
        )

    [account] => Array
        (
            [id] => 1
        )

    [primaryEmail] => Array
        (
            [emailAddress] => a@example.com
            [optOut] => 1
        )

    [secondaryEmail] => Array
        (
            [emailAddress] => b@example.com
            [optOut] => 0
            [isInvalid] => 1
        )

    [primaryAddress] => Array
        (
            [street1] => 129 Noodle Boulevard
            [street2] => Apartment 6000A
            [city] => Noodleville
            [postalCode] => 23453
            [country] => The Good Old US of A
        )

    [secondaryAddress] => Array
        (
            [street1] => 25 de Agosto 2543
            [street2] => Local 3
            [city] => Ciudad de Los Fideos
            [postalCode] => 5123-4
            [country] => Latinoland
        )
    [modelRelations] => Array
        (
            [opportunities] => Array
                (
                    [0] => Array
                        (
                            [action] => add
                            [modelId] => 4
                        )
                )
        )
)
  • PHP sample:
$authenticationData = login('super','super');
//Add code to check if user is logged successfully

$headers = array(
    'Accept: application/json',
    'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
    'ZURMO_TOKEN: ' . $authenticationData['token'],
    'ZURMO_API_REQUEST_TYPE: REST',
);
$data = Array
(
    'firstName' => 'Michael',
    'lastName' => 'Smith',
    'jobTitle' => 'pre class="prettyprint linenums"sident',
    '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
        ),

    'account' => Array
        (
            'id' => 1
        ),

    'primaryEmail' => Array
        (
            'emailAddress' => 'a@example.com',
            'optOut' => 1,
        )

    'secondaryEmail' => Array
        (
            'emailAddress' => 'b@example.com',
            'optOut' => 0,
            'isInvalid' => 1,
        ),

    'primaryAddress' => Array
        (
            'street1' => '129 Noodle Boulevard',
            'street2' => 'Apartment 6000A',
            'city' => 'Noodleville',
            'postalCode' => '23453',
            'country' => 'The Good Old US of A',
        ),

    'secondaryAddress' => Array
        (
            'street1' => '25 de Agosto 2543',
            'street2' => 'Local 3',
            'city' => 'Ciudad de Los Fideos',
            'postalCode' => '5123-4',
            'country' => 'Latinoland',
        ),
);
$data['modelRelations'] = array(
    'opportunities' => array(
        array(
            'action' => 'add',
            'modelId' => 3
        ),
    ),
);
$response = ApiRestHelper::createApiCall('http://crmme_url/index.php/contacts/contact/api/create/', 'POST', $headers, array('data' => $data));
$response = json_decode($response, true);

if ($response['status'] == 'SUCCESS')
{
    $contact = $response['data'];
    //Do something with contact data
}
else
{
    // Error
    $errors = $response['errors'];
    // Do something with errors, show them to user
}
  • Return:
{
  "status":"SUCCESS",
  "data":{
    "id":2,
    "companyName":"Michael Co",
    "description":"Some desc.",
    "website":"http:\/\/sample.com",
    "account":{
      "id":1
    },
    "industry":{
      "id":3,
      "value":"Financial Services"
    },
    "secondaryAddress":{
      "id":2,
      "city":"Ciudad de Los Fideos",
      "country":"Latinoland",
      "invalid":"0",
      "latitude":null,
      "longitude":null,
      "postalCode":"5123-4",
      "street1":"25 de Agosto 2543",
      "street2":"Local 3",
      "state":null
    },
    "secondaryEmail":{
      "id":2,
      "emailAddress":"b@example.com",
      "isInvalid":"1",
      "optOut":"0"
    },
    "source":{
      "id":4,
      "value":"Outbound"
    },
    "state":{
      "id":5
    },
    "department":"Sales",
    "firstName":"Michael",
    "jobTitle":"pre class="prettyprint linenums"sident",
    "lastName":"Smith",
    "mobilePhone":"653-235-7821",
    "officePhone":"653-235-7824",
    "officeFax":"653-235-7834",
    "primaryAddress":{
      "id":1,
      "city":"Noodleville",
      "country":"The Good Old US of A",
      "invalid":"0",
      "latitude":null,
      "longitude":null,
      "postalCode":"23453",
      "street1":"129 Noodle Boulevard",
      "street2":"Apartment 6000A",
      "state":null
    },
    "primaryEmail":{
      "id":1,
      "emailAddress":"a@example.com",
      "isInvalid":null,
      "optOut":"1"
    },
    "title":{
      "id":2,
      "value":"Dr."
    },
    "owner":{
      "id":1,
      "username":"super"
    },
    "createdDateTime":"2012-05-07 08:40:17",
    "modifiedDateTime":"2012-05-07 08:40:17",
    "createdByUser":{
      "id":1,
      "username":"super"
    },
    "modifiedByUser":{
      "id":1,
      "username":"super"
    }
  },
  "message":null,
  "errors":null
}

Update existing contact

Replace %id% with the id of the contact that you want to update, %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Update existing contact by id
  • URL structure: http://crmme_url/index.php/contacts/contact/api/update/%id%
  • Method: PUT
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters:
    All parameters are optional, so you can only provide properties that you want to update.
    For example:
$data = Array
(
    [firstName] => 'Steve'
    [department] => 'Billing'
    [modelRelations] => Array
        (
            [opportunities] => Array
                (
                    [0] => Array
                        (
                            [action] => add
                            [modelId] => 3
                        )
                )
        )
)
  • PHP sample:
$id = 1; // Change this value to contact id that you want to change
$authenticationData = login('super','super');
//Add code to check if user is logged successfully

$headers = array(
    'Accept: application/json',
    'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
    'ZURMO_TOKEN: ' . $authenticationData['token'],
    'ZURMO_API_REQUEST_TYPE: REST',
);
// Change contact first name and department
$data['firstName']                = "John";
$data['department']               = "Billing";
$data['modelRelations'] = array(
    'opportunities' => array(
        array(
            'action' => 'add',
            'modelId' => 3
        ),
        array(
            'action' => 'remove',
            'modelId' => 5
        ),
    ),
);
$response = ApiRestHelper::createApiCall('http://crmme_url/index.php/contacts/contact/api/update/' . $id, 'PUT', $headers, array('data' => $data));
$response = json_decode($response, true);
if ($response['status'] == 'SUCCESS')
{
    $contact = $response['data'];
    //Do something with account data
}
else
{
    // Error, for example if we provided invalid contact id
    $errors = $response['errors'];
    // Do something with errors
}
  • Return:
    Code will return complete updated contact info.
{
  "status":"SUCCESS",
  "data":{
    "id":2,
    "companyName":"Michael Co",
    "description":"Some desc.",
    "website":"http:\/\/sample.com",
    "account":{
      "id":1
    },
    "industry":{
      "id":3,
      "value":"Financial Services"
    },
    "secondaryAddress":{
      "id":2,
      "city":"Ciudad de Los Fideos",
      "country":"Latinoland",
      "invalid":"0",
      "latitude":null,
      "longitude":null,
      "postalCode":"5123-4",
      "street1":"25 de Agosto 2543",
      "street2":"Local 3",
      "state":null
    },
    "secondaryEmail":{
      "id":2,
      "emailAddress":"b@example.com",
      "isInvalid":"1",
      "optOut":"0"
    },
    "source":{
      "id":4,
      "value":"Outbound"
    },
    "state":{
      "id":5
    },
    "department":"Billing",
    "firstName":"John",
    "jobTitle":"pre class="prettyprint linenums"sident",
    "lastName":"Smith",
    "mobilePhone":"653-235-7821",
    "officePhone":"653-235-7824",
    "officeFax":"653-235-7834",
    "primaryAddress":{
      "id":1,
      "city":"Noodleville",
      "country":"The Good Old US of A",
      "invalid":"0",
      "latitude":null,
      "longitude":null,
      "postalCode":"23453",
      "street1":"129 Noodle Boulevard",
      "street2":"Apartment 6000A",
      "state":null
    },
    "primaryEmail":{
      "id":1,
      "emailAddress":"a@example.com",
      "isInvalid":null,
      "optOut":"1"
    },
    "title":{
      "id":2,
      "value":"Dr."
    },
    "owner":{
      "id":1,
      "username":"super"
    },
    "createdDateTime":"2012-05-07 08:40:17",
    "modifiedDateTime":"2012-05-07 08:40:17",
    "createdByUser":{
      "id":1,
      "username":"super"
    },
    "modifiedByUser":{
      "id":1,
      "username":"super"
    }
  },
  "message":null,
  "errors":null
}

Search contacts

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Search contacts
  • URL structure: http://crmme_url/index.php/contacts/contact/api/list/filter/%searchFilter%
  • Method: GET
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Query parameters:
$searchFilter = Array
(
    [pagination] => Array
        (
            [page] => 1
            [pageSize] => 3
        )
    [search] => Array
        (
            [firstName] => 'Peter'

            [account] => Array
                (
                    [id] => 1
                )

            [owner] => Array
                (
                    [id] => 1
                )
        )
    [sort] => firstName.desc
)
  • PHP sample:
$authenticationData = login('super','super');
//Add code to check if user is logged successfully

$headers = array(
    'Accept: application/json',
    'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
    'ZURMO_TOKEN: ' . $authenticationData['token'],
    'ZURMO_API_REQUEST_TYPE: REST',
);
$searchParams = array(
    'pagination' => array(
        'page'     => 1,
        'pageSize' => 3,
    ),
    'search' => array(
        'firstName' => 'Peter',
        'account' => array('id' => '1'),
        'owner' => array('id' => '1'),
    ),
    'sort' => 'firstName.desc',
);
// Get first page of results
$searchParamsQuery = http_build_query($searchParams);
$response = ApiRestTestHelper::createApiCall('http://crmme_url/index.php/contacts/contact/api/list/filter/' . $searchParamsQuery, 'GET', $headers);
$response = json_decode($response, true);
if ($response['status'] == 'SUCCESS')
{
    // Do something with results
    if ($response['data']['totalCount'] > 0)
    {
        foreach ($response['data']['items'] as $item)
        {
        // Print contacts
        }
    }
    else
    {
     // There are no contacts
    }
}
else
{
    $errors = $response['errors'];
    // Do something with errors
}
// Now get second page (you might wanted to check if there are results on second page first)
$searchParams = array(
    'pagination' => array(
        'page'     => 2,
        'pageSize' => 3,
    ),
    'search' => array(
        'firstName' => 'Alex',
    ),
    'sort' => 'firstName',
);
// Get first page of results
$searchParamsQuery = http_build_query($searchParams);
$response = ApiRestTestHelper::createApiCall('http://crmme_url/index.php/contacts/contact/api/list/filter/' . $searchParamsQuery, 'GET', $headers);
$response = json_decode($response, true);
if ($response['status'] == 'SUCCESS')
{
    // Do something with results
    if ($response['data']['totalCount'] > 0)
    {
        foreach ($response['data']['items'] as $item)
        {
        // Print contacts
        }
    }
    else
    {
     // There are no contacts
    }
}
else
{
    $errors = $response['errors'];
    // Do something with errors
}
  • Return:
{
  "status":"SUCCESS",
  "data":{
    "totalCount":"5",
    "currentPage":2,
    "items":[
      {
        "id":3,
        "createdDateTime":"2012-05-07 11:38:21",
        "modifiedDateTime":"2012-05-07 11:38:21",
        "createdByUser":{
          "id":1,
          "username":"super"
        },
        "modifiedByUser":{
          "id":1,
          "username":"super"
        },
        "owner":{
          "id":1,
          "username":"super"
        },
        "department":null,
        "firstName":"First Contact",
        "jobTitle":null,
        "lastName":"First Contactson",
        "mobilePhone":null,
        "officePhone":null,
        "officeFax":null,
        "primaryAddress":null,
        "primaryEmail":null,
        "title":null,
        "companyName":null,
        "description":null,
        "website":null,
        "account":{
          "id":2
        },
        "industry":null,
        "secondaryAddress":null,
        "secondaryEmail":null,
        "source":null,
        "state":{
          "id":5
        }
      },
      {
        "id":7,
        "createdDateTime":"2012-05-07 11:38:22",
        "modifiedDateTime":"2012-05-07 11:38:22",
        "createdByUser":{
          "id":1,
          "username":"super"
        },
        "modifiedByUser":{
          "id":1,
          "username":"super"
        },
        "owner":{
          "id":1,
          "username":"super"
        },
        "department":null,
        "firstName":"Fifth Contact",
        "jobTitle":null,
        "lastName":"Fifth Contactson",
        "mobilePhone":null,
        "officePhone":null,
        "officeFax":null,
        "primaryAddress":null,
        "primaryEmail":null,
        "title":null,
        "companyName":null,
        "description":null,
        "website":null,
        "account":{
          "id":3
        },
        "industry":null,
        "secondaryAddress":null,
        "secondaryEmail":null,
        "source":null,
        "state":{
          "id":5
        }
      }
    ]
  },
  "message":null,
  "errors":null
}</pre class="prettyprint linenums">

Contacts Dynamic Search

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Dynamic search contacts
  • URL structure: http://crmme_url/index.php/contacts/contact/api/list/filter/
  • Method: GET, POST
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Query parameters:
$data = Array
(
    [dynamicSearch] => Array
        (
            [dynamicClauses] => Array
                (
                    [0] => Array
                        (
                            [attributeIndexOrDerivedType] => owner
                            [structurePosition] => 1
                            [owner] => Array
                                (
                                    [id] => 3
                                )

                        )

                    [1] => Array
                        (
                            [attributeIndexOrDerivedType] => name
                            [structurePosition] => 2
                            [firstName] => Fi
                        )

                    [2] => Array
                        (
                            [attributeIndexOrDerivedType] => name
                            [structurePosition] => 3
                            [firstName] => Se
                        )

                )

            [dynamicStructure] => 1 AND (2 OR 3)
        )

    [pagination] => Array
        (
            [page] => 1
            [pageSize] => 2
        )

    [sort] => firstName.asc
)
  • PHP sample:
$authenticationData = login('super','super');
//Add code to check if user is logged successfully

$headers = array(
    'Accept: application/json',
    'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
    'ZURMO_TOKEN: ' . $authenticationData['token'],
    'ZURMO_API_REQUEST_TYPE: REST',
);
$data = array(
    'dynamicSearch' => array(
        'dynamicClauses' => array(
            array(
                'attributeIndexOrDerivedType' => 'owner',
                'structurePosition' => 1,
                'owner' => array(
                    'id' => Yii::app()->user->userModel->id,
                ),
            ),
            array(
                'attributeIndexOrDerivedType' => 'name',
                'structurePosition' => 2,
                'firstName' => 'Fi',
            ),
            array(
                'attributeIndexOrDerivedType' => 'name',
                'structurePosition' => 3,
                'firstName' => 'Se',
            ),
        ),
        'dynamicStructure' => '1 AND (2 OR 3)',
    ),
    'pagination' => array(
        'page'     => 1,
        'pageSize' => 2,
    ),
    'sort' => 'firstName.asc',
);

// Get first page of results
$response = ApiRestTestHelper::createApiCall('http://crmme_url/index.php/contacts/contact/api/list/filter/', 'POST', $headers, array('data' => $data));
$response = json_decode($response, true);
if ($response['status'] == 'SUCCESS')
{
    // Do something with results
    if ($response['data']['totalCount'] > 0)
    {
        foreach ($response['data']['items'] as $item)
        {
        // Print contacts
        }
    }
    else
    {
     // There are no contacts
    }
}
else
{
    $errors = $response['errors'];
    // Do something with errors
}
  • Return:
{
  "status":"SUCCESS",
  "data":{
    "totalCount":"5",
    "currentPage":2,
    "items":[
      {
        "id":3,
        "createdDateTime":"2012-05-07 11:38:21",
        "modifiedDateTime":"2012-05-07 11:38:21",
        "createdByUser":{
          "id":1,
          "username":"super"
        },
        "modifiedByUser":{
          "id":1,
          "username":"super"
        },
        "owner":{
          "id":1,
          "username":"super"
        },
        "department":null,
        "firstName":"First Contact",
        "jobTitle":null,
        "lastName":"First Contactson",
        "mobilePhone":null,
        "officePhone":null,
        "officeFax":null,
        "primaryAddress":null,
        "primaryEmail":null,
        "title":null,
        "companyName":null,
        "description":null,
        "website":null,
        "account":{
          "id":2
        },
        "industry":null,
        "secondaryAddress":null,
        "secondaryEmail":null,
        "source":null,
        "state":{
          "id":5
        }
      },
      {
        "id":7,
        "createdDateTime":"2012-05-07 11:38:22",
        "modifiedDateTime":"2012-05-07 11:38:22",
        "createdByUser":{
          "id":1,
          "username":"super"
        },
        "modifiedByUser":{
          "id":1,
          "username":"super"
        },
        "owner":{
          "id":1,
          "username":"super"
        },
        "department":null,
        "firstName":"Fifth Contact",
        "jobTitle":null,
        "lastName":"Fifth Contactson",
        "mobilePhone":null,
        "officePhone":null,
        "officeFax":null,
        "primaryAddress":null,
        "primaryEmail":null,
        "title":null,
        "companyName":null,
        "description":null,
        "website":null,
        "account":{
          "id":3
        },
        "industry":null,
        "secondaryAddress":null,
        "secondaryEmail":null,
        "source":null,
        "state":{
          "id":5
        }
      }
    ]
  },
  "message":null,
  "errors":null
}

Contacts Improved Search

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Search contacts – improved
  • URL structure: http://crmme_url/index.php/contacts/contact/api/search/filter/
  • Method: GET, POST
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Query parameters:
$data = Array
(
    [search] => Array
        (
            [modelClassName] => Contact
            [searchAttributeData] => Array
                (
                    [clauses] => Array
                        (
                            [1] => Array
                                (
                                    [attributeName] => owner
                                    [relatedAttributeName] => id
                                    [operatorType] => equals
                                    [value] => 1
                                )
                            [2] => Array
                                (
                                    [attributeName] => firstName
                                    [operatorType] => startsWith
                                    [value] => Fi
                                )
                            [3] => Array
                                (
                                    [attributeName] => firstName
                                    [operatorType] => startsWith
                                    [value] => Se
                                )
                        )
                    [structure] => 1 AND (2 OR 3)
                )
        )
    [pagination] => Array
        (
            [page] => 1
            [pageSize] => 2
        )
    [sort] => firstName asc
)
  • PHP sample:
$authenticationData = login('super','super');
//Add code to check if user is logged successfully

$headers = array(
    'Accept: application/json',
    'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
    'ZURMO_TOKEN: ' . $authenticationData['token'],
    'ZURMO_API_REQUEST_TYPE: REST',
);
$data = array(
  'search' => array(
    'modelClassName' => 'Contact',
    'searchAttributeData' => array(
      'clauses' => array(
         1 => array(
           'attributeName'        => 'owner',
           'relatedAttributeName' => 'id',
           'operatorType'         => 'equals',
           'value'                => $userId,
         ),
         2 => array(
           'attributeName'        => 'firstName',
           'operatorType'         => 'startsWith',
           'value'                => 'Fi'
         ),
         3 => array(
           'attributeName'        => 'firstName',
           'operatorType'         => 'startsWith',
           'value'                => 'Se'
         ),
      ),
      'structure' => '1 AND (2 OR 3)',
    ),
  ),
  'pagination' => array(
    'page'     => 1,
    'pageSize' => 2,
  ),
  'sort' => 'firstName asc',
);

// Get first page of results
$response = ApiRestTestHelper::createApiCall('http://crmme_url/index.php/contacts/contact/api/search/filter/', 'POST', $headers, array('data' => $data));
$response = json_decode($response, true);
if ($response['status'] == 'SUCCESS')
{
    // Do something with results
    if ($response['data']['totalCount'] > 0)
    {
        foreach ($response['data']['items'] as $item)
        {
        // Print contacts
        }
    }
    else
    {
     // There are no contacts
    }
}
else
{
    $errors = $response['errors'];
    // Do something with errors
}
  • Return:
{
  "status":"SUCCESS",
  "data":{
    "totalCount":"5",
    "currentPage":2,
    "items":[
      {
        "id":3,
        "createdDateTime":"2012-05-07 11:38:21",
        "modifiedDateTime":"2012-05-07 11:38:21",
        "createdByUser":{
          "id":1,
          "username":"super"
        },
        "modifiedByUser":{
          "id":1,
          "username":"super"
        },
        "owner":{
          "id":1,
          "username":"super"
        },
        "department":null,
        "firstName":"First Contact",
        "jobTitle":null,
        "lastName":"First Contactson",
        "mobilePhone":null,
        "officePhone":null,
        "officeFax":null,
        "primaryAddress":null,
        "primaryEmail":null,
        "title":null,
        "companyName":null,
        "description":null,
        "website":null,
        "account":{
          "id":2
        },
        "industry":null,
        "secondaryAddress":null,
        "secondaryEmail":null,
        "source":null,
        "state":{
          "id":5
        }
      },
      {
        "id":7,
        "createdDateTime":"2012-05-07 11:38:22",
        "modifiedDateTime":"2012-05-07 11:38:22",
        "createdByUser":{
          "id":1,
          "username":"super"
        },
        "modifiedByUser":{
          "id":1,
          "username":"super"
        },
        "owner":{
          "id":1,
          "username":"super"
        },
        "department":null,
        "firstName":"Fifth Contact",
        "jobTitle":null,
        "lastName":"Fifth Contactson",
        "mobilePhone":null,
        "officePhone":null,
        "officeFax":null,
        "primaryAddress":null,
        "primaryEmail":null,
        "title":null,
        "companyName":null,
        "description":null,
        "website":null,
        "account":{
          "id":3
        },
        "industry":null,
        "secondaryAddress":null,
        "secondaryEmail":null,
        "source":null,
        "state":{
          "id":5
        }
      }
    ]
  },
  "message":null,
  "errors":null
}

List Contact Attributes

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by authentication process.

  • Description: List contact attributes.
  • URL structure: http://crmme_url/index.php/contacts/contact/api/listAttributes
  • Method: GET
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters: None
  • PHP sample
$authenticationData = login('super','super');
//Add code to check if user is logged successfully

$headers = array(
    'Accept: application/json',
    'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
    'ZURMO_TOKEN: ' . $authenticationData['token'],
    'ZURMO_API_REQUEST_TYPE: REST',
);
$response = ApiRestHelper::createApiCall('http://crmme_url/index.php/contacts/contact/api/listAttributes', 'GET', $headers);
// Decode json data
$response = json_decode($response, true);
if ($response['status'] == 'SUCCESS')
{
    $contactAttributes = $response['data'];
    //Do something with contact attributes
}
else
{
    // Error
    $errors = $response['errors'];
    // Do something with errors
}
  • Return:
    Data contains contact attributes info.

Have more questions? Submit a request

Comments

Powered by Zendesk