Create Customer Sites
From MyMobileWorkers API
Revision as of 14:18, 31 October 2013 by Darren.atherton (Talk | contribs)
Contents |
Summary
The create customer contacts action allows users to attach a contacts to a customer. This method accepts an array of contacts to be added to the system. A contact can be created via two different methods - either as multi-part form data with a JSON file attached and the API key as a parameter, or as JSON content on it's own, with the API key supplied within the JSON.
Multi Part Form Data
| Create Customer Contact | ||
|---|---|---|
| URL | http://base_url/api_path/version/companies/company/customers/contacts | |
| Type | POST | |
| Params: | api_key | required |
| file | required | |
| Response | JSON | |
JSON As Body
| Create Customer Contact - JSON | ||
|---|---|---|
| URL | http://base_url/api_path/version/companies/company/customers/contacts | |
| Type | POST | |
| JSON {key, validate_only(optional), update_existing(optional), customers[]} |
required | |
| Response | JSON | |
JSON Contents
| Standard Fields | ||
|---|---|---|
| Field | Expected Data | Required |
| customer | {"name":"<customer name>"} *nested JSON object |
✓ |
| contact_name | varchar(45) | ✓ |
| external_id | varchar(45) | |
| address_1 | varchar(45) | ✓ |
| address_2 | varchar(45) | |
| address_3 | varchar(45) | |
| address_4 | varchar(45) | |
| postcode | varchar(45) | ✓ |
| contact_number | varchar(45) | ✓ |
| Standard Fields | ||
|---|---|---|
| Field | Expected Data | Required |
| key | string - company api key | ✓ |
| updating_existing | boolean | |
| validate_only | boolean | |
Example Input
Multi Part Form Data
{ "customer_contacts":[ { "external_id":"Contact1", "contact_name":"test_contact", "customer_id":{ "name":"test" }, "address_1":"8 The Parks", "address_2":"address 3", "address_3":"address 4", "address_4":"address 5", "postcode":"WA12 0JQ", "contact_number":"01234567891" } ] }
JSON As Body
{ "key":"testkey", "validate_only":"false", "update_existing":"true", "customer_contacts":[ { "external_id":"Contact1", "contact_name":"test_contact", "customer_id":{ "name":"test" }, "address_1":"8 The Parks", "address_2":"address 3", "address_3":"address 4", "address_4":"address 5", "postcode":"WA12 0JQ", "contact_number":"01234567891" } ] }
Example Curl Requests
Multi Part Form Data
curl -F validate_only=false -F update_existing=true -F api_key=testkey -F file=@/Users/testuser/Desktop/webAPICurling/create_customer_contacts.txt http://live.mymobileworkers.com:8080/api/1/companies/company/customers/contacts
JSON As Body
curl -X POST -H "Content-Type: application/json" -d '{
"key":"testkey",
"validate_only":"false",
"update_existing":"true",
"customer_contacts":[
{
"external_id":"Contact1",
"contact_name":"test_contact",
"customer_id":{
"name":"test"
},
"address_1":"8 The Parks",
"address_2":"address 3",
"address_3":"address 4",
"address_4":"address 5",
"postcode":"WA12 0JQ",
"contact_number":"01234567891"
}
]
}' http://live.mymobileworkers.com:8080/api/1/companies/company/customers/contacts
Responses
Example JSON
{ "successful":[ { "contact_name":"test_contact" } ], "failed":[ { "contact_name":"test_contact", "errors":[ { "error_code":"CCV002", "error_message":"Address 1 cannot be null." } ] } ] }