drus39136 2016-06-16 16:52
浏览 20
已采纳

ServiceM8通过API创建新工作

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

  • 写回答

1条回答 默认 最新

  • dongsigan2044 2016-06-19 23:52
    关注

    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:

    1. POST your job details (status, job_address, job_description) to the Job endpoint
    2. Inspect the x-record-uuid header to determine the UUID of the job you just created
    3. 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
      }
      
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line