Difference between revisions of "Create Job Parts"
(→Summary) |
(→JSON As Body) |
||
| (11 intermediate revisions by 3 users not shown) | |||
| Line 2: | Line 2: | ||
== Summary == | == Summary == | ||
| − | Job parts can | + | Job parts can be created for any workflow type however for the data to be displayed on the device the correct screen needs to be enabled. |
| + | |||
A job part 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. | A job part 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. | ||
| + | |||
| + | A job part may be created either by supplying freeform text for the 'name' field, or by supplying the name or external id of an existing part, which will then be linked from the items catalog to the new part. | ||
This method is transactional. If one part fails validation, then no parts will be created. | This method is transactional. If one part fails validation, then no parts will be created. | ||
| Line 12: | Line 15: | ||
{| border="1" class="wikitable" | {| border="1" class="wikitable" | ||
| − | ! Create Job | + | ! Create Job Part |
! colspan="2" | | ! colspan="2" | | ||
|- | |- | ||
! URL | ! URL | ||
| − | | colspan="2" | | + | | colspan="2" | https://:base_url/:api_path/:version/jobs/job/parts |
|- | |- | ||
! Type | ! Type | ||
| Line 36: | Line 39: | ||
==== JSON As Body ==== | ==== JSON As Body ==== | ||
{| border="1" class="wikitable" | {| border="1" class="wikitable" | ||
| − | ! Create Job - JSON | + | ! Create Job Part - JSON |
! colspan="2" | | ! colspan="2" | | ||
|- | |- | ||
! URL | ! URL | ||
| − | | colspan="2" | | + | | colspan="2" | https://:base_url/:api_path/:version/jobs/job/parts |
|- | |- | ||
! Type | ! Type | ||
| Line 60: | Line 63: | ||
! Required | ! Required | ||
|- | |- | ||
| − | ! name | + | ! name OR external_id |
| varchar(45) || ✓ | | varchar(45) || ✓ | ||
|- | |- | ||
| Line 85: | Line 88: | ||
| string - company api key || ✓ | | string - company api key || ✓ | ||
|- | |- | ||
| − | ! | + | ! update_existing |
| boolean || | | boolean || | ||
|- | |- | ||
| Line 92: | Line 95: | ||
|- | |- | ||
|} | |} | ||
| − | |||
== Example Input == | == Example Input == | ||
| Line 129: | Line 131: | ||
==== Multi Part Form Data ==== | ==== Multi Part Form Data ==== | ||
| − | curl -F validate_only=false -F update_existing=true -F api_key=darrenwebapi -F job_number=123 -F file=@/Users/darrenatherton/Desktop/webAPICurling/create_job_part_stage.txt | + | curl -F validate_only=false -F update_existing=true -F api_key=darrenwebapi -F job_number=123 -F file=@/Users/darrenatherton/Desktop/webAPICurling/create_job_part_stage.txt https://api.mymobileworkers.com:8181/api/1/jobs/job/parts |
==== JSON As Body ==== | ==== JSON As Body ==== | ||
| − | curl -X POST -H "Content-Type: application/json" -d '{"key":"darrenwebapi","job_number":"123","parts":[{"quantity":"4","external_id":"testingThis","description":"testDescription","code":"helloCode"}]}' | + | curl -X POST -H "Content-Type: application/json" -d '{"key":"darrenwebapi","job_number":"123","parts":[{"quantity":"4","external_id":"testingThis","description":"testDescription","code":"helloCode"}]}' https://api.mymobileworkers.com:8181/api/1/jobs/job/parts |
== Responses == | == Responses == | ||
Latest revision as of 12:35, 14 November 2016
Contents |
[edit] Summary
Job parts can be created for any workflow type however for the data to be displayed on the device the correct screen needs to be enabled.
A job part 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.
A job part may be created either by supplying freeform text for the 'name' field, or by supplying the name or external id of an existing part, which will then be linked from the items catalog to the new part.
This method is transactional. If one part fails validation, then no parts will be created.
Returns a list of valid job parts and a list of failed job parts. Even if parts are valid, they will not be created unless there are no failed parts.
[edit] Multi Part Form Data
| Create Job Part | ||
|---|---|---|
| URL | https://:base_url/:api_path/:version/jobs/job/parts | |
| Type | POST | |
| Params: | api_key | required |
| file | required | |
| job_number | required | |
| Response | JSON | |
[edit] JSON As Body
| Create Job Part - JSON | ||
|---|---|---|
| URL | https://:base_url/:api_path/:version/jobs/job/parts | |
| Type | POST | |
| JSON {key, validate_only(optional), update_existing(optional), items[]} |
required | |
| Response | JSON | |
[edit] JSON Contents
| Field | Expected Data | Required |
|---|---|---|
| name OR external_id | varchar(45) | ✓ |
| code | varchar(45) | ✓ |
| quantity | double | ✓ |
| description | varchar(255) | ✓ |
| Standard Fields | ||
|---|---|---|
| Field | Expected Data | Required |
| key | string - company api key | ✓ |
| update_existing | boolean | |
| validate_only | boolean | |
[edit] Example Input
[edit] Multi Part Form Data
{"parts":[{ "quantity":"4", "external_id":"testingThis", "description":"testDescription", "code":"helloCode" }]}
[edit] JSON As Body
{ "key":"darrenwebapi", "job_number":"123", "parts":[ { "quantity":"4", "external_id":"testingThis", "description":"testDescription", "code":"helloCode" } ] }
[edit] Example Curl Requests
[edit] Multi Part Form Data
curl -F validate_only=false -F update_existing=true -F api_key=darrenwebapi -F job_number=123 -F file=@/Users/darrenatherton/Desktop/webAPICurling/create_job_part_stage.txt https://api.mymobileworkers.com:8181/api/1/jobs/job/parts
[edit] JSON As Body
curl -X POST -H "Content-Type: application/json" -d '{"key":"darrenwebapi","job_number":"123","parts":[{"quantity":"4","external_id":"testingThis","description":"testDescription","code":"helloCode"}]}' https://api.mymobileworkers.com:8181/api/1/jobs/job/parts
[edit] Responses
[edit] Example JSON
{ "result":"failed", "failed":[ { "part":{ "name":"part2", "code":null, "description":null, "quantity":0.0 }, "errors":[ { "error_code":"WAJ037", "error_message":"code invalid empty string" }, { "error_code":"WAJ034", "error_message":"description invalid empty string" } ] } ], "valid":[ { "name":"part1", "code":"CODE1", "description":"description", "quantity":1.0 } ] }