问题描述
我正在尝试访问 ServiceM8 中已完成的表单字段数据,包括上传的图像.api 参考没有详细说明如何访问它们.谁能提供示例或文档?
它没有公开记录,但您可以通过 FormResponses 端点访问完成的表单.
https://api.servicem8.com/api_1.0/FormResponse.json
[{"edit_date": "2015-02-17 11:12:22",活跃":1,"form_uuid": "578344cc-8d57-441b-a713-02207430f7cb","staff_uuid": "","regarding_object": "工作","regarding_object_uuid": "8b9bfe73-c43c-4275-bb4e-1aac9b6f8adb","field_data": "已删除(见下文)","时间戳": "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"}]
问题的实际回答在 field_data
属性中,它本身是一个 JSON 编码的字符串.举个例子:
对于照片问题(FieldType == Photo),Response 属性包含一个 UUID,您可以从 附件端点.
附件的JSON数据:https://api.servicem8.com/api_1.0/Attachment/cf91bae2-b9da-42e2-87ee-b416109bb44b.json
文件数据(即附件本身):https://api.servicem8.com/api_1.0/Attachment/cf91bae2-b9da-42e2-87ee-b416109bb44b.file
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?
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
这篇关于访问 ServiceM8 中已完成的表单字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!