Difference between revisions of "Create Company Attachment Folders"
From MyMobileWorkers API
(→JSON As Body) |
(→Multi Part Form Data) |
||
| Line 8: | Line 8: | ||
{| border="1" class="wikitable" | {| border="1" class="wikitable" | ||
| − | ! Create | + | ! Create Item |
! colspan="2" | | ! colspan="2" | | ||
|- | |- | ||
! URL | ! URL | ||
| − | | colspan="2" | http:// | + | | colspan="2" | http://base_url/api_path/version/companies/company/attachment_folders |
|- | |- | ||
! Type | ! Type | ||
| Line 21: | Line 21: | ||
|- | |- | ||
! | ! | ||
| − | | | + | | file || required |
|- | |- | ||
! | ! | ||
| − | | update_existing | + | | update_existing || optional (default = false) |
| + | |- | ||
| + | ! | ||
| + | | validate_only || optional (default = false) | ||
|- | |- | ||
| − | |||
! Response | ! Response | ||
| colspan="2" | JSON | | colspan="2" | JSON | ||
Revision as of 10:52, 12 March 2018
Contents |
Summary
A company folder 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.
Multi Part Form Data
| Create Item | ||
|---|---|---|
| URL | http://base_url/api_path/version/companies/company/attachment_folders | |
| Type | POST | |
| Params: | api_key | required |
| file | required | |
| update_existing | optional (default = false) | |
| validate_only | optional (default = false) | |
| Response | JSON | |
JSON As Body
| Create Job - JSON | ||
|---|---|---|
| URL | http://:base_url/:api_path/:version/companies/company/attachment_folders | |
| Type | POST | |
| JSON {key, validate_only(optional), update_existing(optional), folders[]} |
required | |
| Response | JSON | |
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(45) |
| 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 Input
Multi Part Form Data
{"items":[{ "type":"C", "expected_quantity":"4", "other":"test", "notes":"exampleNotes", "name":"darrenItem245", "barcodes":"barcode,barcode1" }]}
JSON As Body
{ "key":"darrenwebapi", "job_number":"123", "items":[ { "type":"C", "expected_quantity":"4", "other":"test", "notes":"exampleNotes", "name":"darrenItem", "barcodes":"barcode,barcode1" } ] }
Example Curl Requests
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
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
Responses
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" } ] }