I'm sending the following JSON to the SM8 API https://api.servicem8.com/api_1.0/job.json
The response I am getting is 200 OK
, & the job is being created in my servicem8 dashboard, but the name and description fields are not being populated for some reason.
Also, I was hoping to capture the newly created job ID from the response object, but it is either not being returned or I am unsure how to access it.
Here's the JSON that I'm passing to the API:
{
"status":"Quote",
"job_address":"123 Street Lane, , London, SE2",
"description":"Remove & replace existing carpets",
"contact_first":"Joe",
"contact_last":"Bloggs"
}
Anyone see what the problem is?
Cheers
The UUID of newly created records is returned in a HTTP header called x-record-uuid
when you initially create the record.
The description is not being populated because the field name needs to be job_description
(rather than description
).
Contact details for jobs need to be populated through the JobContacts endpoint ( http://developer.servicem8.com/docs/rest-api/reference/jobcontact-3/ ). contact_first
and contact_last
aren't valid field names for Job objects.
So for your example record you will need to do the following:
POST another request to the JobContact endpoint to create a contact for the job. Set the job_uuid to the UUID of the job that was created. You will probably want to set type=JOB and is_primary_contact=1. It will look something like this:
{ "first":"Joe", "last":"Bloggs", "job_uuid":"7d97be49-0eff-417a-8251-ab8b8942d65b", "type":"JOB", "is_primary_contact":1 }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.