I am trying to access completed form field data in ServiceM8 including uploaded images. The api reference does not detail how to access them. Can anyone provide an example or documentation?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
It's not publicly documented, but you can access completed forms via the FormResponses endpoint.
https://api.servicem8.com/api_1.0/FormResponse.json
[{
"edit_date": "2015-02-17 11:12:22",
"active": 1,
"form_uuid": "578344cc-8d57-441b-a713-02207430f7cb",
"staff_uuid": "",
"regarding_object": "job",
"regarding_object_uuid": "8b9bfe73-c43c-4275-bb4e-1aac9b6f8adb",
"field_data": "removed (see below)",
"timestamp": "2015-02-17 11:12:20",
"form_by_staff_uuid": "0e72af0f-22db-4ddb-ac7d-eba2c1ef2d4b",
"document_attachment_uuid": "6b73bfa3-3dd8-48b7-83b2-af1dcc78262b",
"uuid": "ff1926c8-8879-41a5-9f2d-e4e4455e92eb"
}]
The actual responses to the questions are in the field_data
property, which is itself a JSON-encoded string. Here's an example:
[
{
"UUID": "1ea64222-2b0e-4dc4-a99b-698603a9f59b",
"FieldType": "Date",
"Response": "Tue Feb 17 2015 00:00:00 GMT+0930 (ACST)",
"SortOrder": 1,
"Question": "Date"
},
{
"UUID": "9b4ea087-d154-4fb7-831e-c17cb882157b",
"FieldType": "Multiple Choice",
"Response": "Blah",
"SortOrder": 2,
"Question": "Supplier"
},
{
"UUID": "24fdd846-8fc8-4ddf-9d58-6c5fa1b5310b",
"FieldType": "Text",
"Response": "1",
"SortOrder": 3,
"Question": "Part 1 Qty"
},
{
"UUID": "6162749f-5945-455c-95ca-ca31e9bd6a7b",
"FieldType": "Text",
"Response": "p1",
"SortOrder": 4,
"Question": "Item Part No. 1"
},
{
"UUID": "fd5c8f67-c68d-4dcb-96a7-05341fbb3dab",
"FieldType": "Text",
"Response": "part one",
"SortOrder": 5,
"Question": "Item Name 1"
},
{
"UUID": "6e591103-78d4-42a0-8657-5229b5b469fb",
"FieldType": "Photo",
"Response": "cf91bae2-b9da-42e2-87ee-b416109bb44b",
"SortOrder": 14,
"Question": "Take Photo of Items 1"
},
{
"UUID": "c8719af5-b550-40cf-9d83-0ea67ab30e5b",
"FieldType": "Signature",
"Response": "90ac5b56-fc0e-4a3a-8935-f43cdd23c05b",
"SortOrder": 17,
"Question": "Signature"
}
]
For photo questions (FieldType == Photo), the Response property contains a UUID which you can retrieve from the Attachments endpoint.
JSON data for the attachment: https://api.servicem8.com/api_1.0/Attachment/cf91bae2-b9da-42e2-87ee-b416109bb44b.json
File data (i.e. the attachment itself): https://api.servicem8.com/api_1.0/Attachment/cf91bae2-b9da-42e2-87ee-b416109bb44b.file