Difference between revisions of "Create Job Items"
(→JSON Parameters) |
(→JSON As Body) |
||
| (33 intermediate revisions by 7 users not shown) | |||
| Line 1: | Line 1: | ||
| + | |||
== Summary == | == Summary == | ||
| + | |||
| + | Job items 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 item 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 item 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 item. | ||
| + | |||
| + | This method is transactional. If one item fails validation, then no items will be created. | ||
| + | |||
| + | Returns a list of valid job items and a list of failed job items. Even if items are valid, they will not be created unless there are no failed items. | ||
| + | |||
| + | The replace existing parameter will remove all existing items from the job before the new collection of items is added. | ||
| + | |||
| + | ==== Multi Part Form Data ==== | ||
{| border="1" class="wikitable" | {| border="1" class="wikitable" | ||
| − | ! Create Job | + | ! Create Job item |
! colspan="2" | | ! colspan="2" | | ||
|- | |- | ||
! URL | ! URL | ||
| − | | colspan="2" | http://:base_url/:api_path/:version/jobs/items | + | | colspan="2" | http://:base_url/:api_path/:version/jobs/job/items |
|- | |- | ||
! Type | ! Type | ||
| Line 13: | Line 28: | ||
! Params: | ! Params: | ||
| api_key || required | | api_key || required | ||
| + | |- | ||
| + | ! | ||
| + | | validate_only || required | ||
|- | |- | ||
! | ! | ||
| Line 24: | Line 42: | ||
|} | |} | ||
| + | ==== JSON As Body ==== | ||
| + | {| border="1" class="wikitable" | ||
| + | ! Create Job - JSON | ||
| + | ! colspan="2" | | ||
| + | |- | ||
| + | ! URL | ||
| + | | colspan="2" | http://:base_url/:api_path/:version/jobs/job/items | ||
| + | |- | ||
| + | ! Type | ||
| + | | colspan="2" |POST | ||
| + | |- | ||
| + | ! | ||
| + | | JSON <br /> {key, job_number, validate_only(optional), update_existing(optional), replace_existing(optional), items[]} ||| required | ||
| + | |- | ||
| + | ! Response | ||
| + | | colspan="2" | JSON | ||
| + | |} | ||
| − | + | == JSON Contents == | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | == JSON | + | |
{| border="1" class="wikitable" | {| border="1" class="wikitable" | ||
| Line 39: | Line 68: | ||
! Required | ! Required | ||
|- | |- | ||
| − | ! name | + | ! name OR external_id |
| varchar(45) || ✓ | | varchar(45) || ✓ | ||
|- | |- | ||
| Line 45: | Line 74: | ||
| "C","D" <br /><span style="font-size:80%; font-weight:normal">* Collect/Deliver</span>|| ✓ | | "C","D" <br /><span style="font-size:80%; font-weight:normal">* Collect/Deliver</span>|| ✓ | ||
|- | |- | ||
| − | ! | + | ! expected_quantity |
| int(4) || ✓ | | int(4) || ✓ | ||
| + | |- | ||
| + | ! other | ||
| + | | varchar(45) || | ||
|- | |- | ||
! notes | ! notes | ||
| varchar(45) || | | varchar(45) || | ||
|- | |- | ||
| + | ! barcodes | ||
| + | | varchar(255) || | ||
| + | |- | ||
| + | |} | ||
| + | {| border="1" class="wikitable" | ||
| + | |+ Fields exclusive to JSON body format: | ||
| + | ! colspan="3" | Standard Fields | ||
| + | |- | ||
| + | ! Field | ||
| + | ! Expected Data | ||
| + | ! Required | ||
| + | |- | ||
| + | ! key | ||
| + | | string - company api key || ✓ | ||
| + | |- | ||
| + | ! job_number | ||
| + | | string - job number || ✓ | ||
| + | |- | ||
| + | ! validate_only | ||
| + | | boolean || | ||
| + | |- | ||
| + | ! update_existing | ||
| + | | boolean || | ||
| + | |- | ||
| + | ! replace_existing | ||
| + | | boolean || | ||
| + | |- | ||
|} | |} | ||
| − | == Example | + | == Example Input == |
| + | |||
| + | ==== Multi Part Form Data ==== | ||
<source lang="java"> | <source lang="java"> | ||
| + | {"items":[{ | ||
| + | "type":"C", | ||
| + | "expected_quantity":"4", | ||
| + | "other":"test", | ||
| + | "notes":"exampleNotes", | ||
| + | "name":"darrenItem245", | ||
| + | "barcodes":"barcode,barcode1" | ||
| + | }]} | ||
| + | </source> | ||
| + | ==== JSON As Body ==== | ||
| + | |||
| + | <source lang="java"> | ||
| + | { | ||
| + | "key":"darrenwebapi", | ||
| + | "job_number":"123", | ||
| + | "items":[ | ||
| + | { | ||
| + | "type":"C", | ||
| + | "expected_quantity":"4", | ||
| + | "other":"test", | ||
| + | "notes":"exampleNotes", | ||
| + | "name":"darrenItem", | ||
| + | "barcodes":"barcode,barcode1" | ||
| + | }, | ||
| + | { | ||
| + | "type":"D", | ||
| + | "expected_quantity":"2", | ||
| + | "other":"testing1", | ||
| + | "notes":"noting", | ||
| + | "name":"Item", | ||
| + | "barcodes":"barcode2,barcode2" | ||
| + | } | ||
| + | ] | ||
| + | } | ||
</source> | </source> | ||
| − | == Example curl | + | == Example Curl Requests == |
| + | |||
| + | ==== Multi Part Form Data ==== | ||
| + | |||
| + | <source lang="php"> | ||
| + | curl -F validate_only=false -F update_existing=true -F api_key=[YOUR_API_KEY] -F job_number=123 -F file=@/Users/darrenatherton/Desktop/webAPICurling/create_job_item_stage.txt http://api.mymobileworkers.com:8080/api/1/jobs/job/items | ||
| + | </source> | ||
| + | |||
| + | ==== JSON As Body ==== | ||
| + | |||
| + | <source lang="php"> | ||
| + | curl -X POST -H "Content-Type: application/json" -d '{"key":"YOUR_API_KEY","job_number":"123","items":[{"type":"C","expected_quantity":"4","other":"test","notes":"exampleNotes","name":"darrenItem"}]}' http://api.mymobileworkers.com:8080/api/1/jobs/job/items | ||
| + | </source> | ||
== Responses == | == Responses == | ||
| Line 89: | Line 196: | ||
"type":"C", | "type":"C", | ||
"notes":"notes", | "notes":"notes", | ||
| − | + | "barcodes":"barcode,barcode1" | |
} | } | ||
] | ] | ||
} | } | ||
</source> | </source> | ||
Latest revision as of 09:26, 15 June 2020
Contents |
[edit] Summary
Job items 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 item 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 item 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 item.
This method is transactional. If one item fails validation, then no items will be created.
Returns a list of valid job items and a list of failed job items. Even if items are valid, they will not be created unless there are no failed items.
The replace existing parameter will remove all existing items from the job before the new collection of items is added.
[edit] Multi Part Form Data
| Create Job item | ||
|---|---|---|
| URL | http://:base_url/:api_path/:version/jobs/job/items | |
| Type | POST | |
| Params: | api_key | required |
| validate_only | required | |
| file | required | |
| job_number | required | |
| Response | JSON | |
[edit] JSON As Body
| Create Job - JSON | ||
|---|---|---|
| URL | http://:base_url/:api_path/:version/jobs/job/items | |
| Type | POST | |
| JSON {key, job_number, validate_only(optional), update_existing(optional), replace_existing(optional), items[]} |
required | |
| Response | JSON | |
[edit] JSON Contents
| Field | Expected Data | Required |
|---|---|---|
| name OR external_id | varchar(45) | ✓ |
| type | "C","D" * Collect/Deliver |
✓ |
| expected_quantity | int(4) | ✓ |
| other | varchar(45) | |
| notes | varchar(45) | |
| barcodes | varchar(255) |
| Standard Fields | ||
|---|---|---|
| Field | Expected Data | Required |
| key | string - company api key | ✓ |
| job_number | string - job number | ✓ |
| validate_only | boolean | |
| update_existing | boolean | |
| replace_existing | boolean | |
[edit] Example Input
[edit] Multi Part Form Data
{"items":[{ "type":"C", "expected_quantity":"4", "other":"test", "notes":"exampleNotes", "name":"darrenItem245", "barcodes":"barcode,barcode1" }]}
[edit] JSON As Body
{ "key":"darrenwebapi", "job_number":"123", "items":[ { "type":"C", "expected_quantity":"4", "other":"test", "notes":"exampleNotes", "name":"darrenItem", "barcodes":"barcode,barcode1" }, { "type":"D", "expected_quantity":"2", "other":"testing1", "notes":"noting", "name":"Item", "barcodes":"barcode2,barcode2" } ] }
[edit] Example Curl Requests
[edit] Multi Part Form Data
curl -F validate_only=false -F update_existing=true -F api_key=[YOUR_API_KEY] -F job_number=123 -F file=@/Users/darrenatherton/Desktop/webAPICurling/create_job_item_stage.txt http://api.mymobileworkers.com:8080/api/1/jobs/job/items
[edit] JSON As Body
curl -X POST -H "Content-Type: application/json" -d '{"key":"YOUR_API_KEY","job_number":"123","items":[{"type":"C","expected_quantity":"4","other":"test","notes":"exampleNotes","name":"darrenItem"}]}' http://api.mymobileworkers.com:8080/api/1/jobs/job/items
[edit] Responses
[edit] Example JSON
{ "result":"failed", "failed":[ { "item":{ "name":"item2", "type":null, "notes":null, }, "errors":[ { "error_code":"JBI002", "error_message":"Job item type is null" } ] } ], "valid":[ { "name":"item1", "type":"C", "notes":"notes", "barcodes":"barcode,barcode1" } ] }