Difference between revisions of "Create Job Parts"
(→Summary) |
|||
| Line 1: | Line 1: | ||
| + | |||
== Summary == | == Summary == | ||
| + | |||
| + | Job parts can only be added to a Repair/Field Service job. | ||
| + | A job 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. | ||
| + | |||
| + | 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. | ||
| + | |||
| + | ==== Multi Part Form Data ==== | ||
{| border="1" class="wikitable" | {| border="1" class="wikitable" | ||
| Line 24: | Line 34: | ||
|} | |} | ||
| + | ==== JSON As Body ==== | ||
| + | {| border="1" class="wikitable" | ||
| + | ! Create Job - JSON | ||
| + | ! colspan="2" | | ||
| + | |- | ||
| + | ! URL | ||
| + | | colspan="2" | http://:base_url/:api_path/:version/jobs/job/parts | ||
| + | |- | ||
| + | ! Type | ||
| + | | colspan="2" |POST | ||
| + | |- | ||
| + | ! | ||
| + | | JSON <br /> {key, validate_only(optional), update_existing(optional), items[]} ||| required | ||
| + | |- | ||
| + | ! Response | ||
| + | | colspan="2" | JSON | ||
| + | |} | ||
| − | + | == JSON Contents == | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | == JSON | + | |
{| border="1" class="wikitable" | {| border="1" class="wikitable" | ||
| Line 51: | Line 72: | ||
| varchar(255) || ✓ | | 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 || ✓ | ||
| + | |- | ||
| + | ! updating_existing | ||
| + | | boolean || | ||
| + | |- | ||
| + | ! validate_only | ||
| + | | boolean || | ||
| + | |- | ||
|} | |} | ||
| − | == Example | + | |
| + | == Example Input == | ||
| + | |||
| + | ==== Multi Part Form Data ==== | ||
<source lang="java"> | <source lang="java"> | ||
| + | {"parts":[{ | ||
| + | "quantity":"4", | ||
| + | "external_id":"testingThis", | ||
| + | "description":"testDescription", | ||
| + | "code":"helloCode" | ||
| + | }]} | ||
| + | </source> | ||
| + | |||
| + | ==== JSON As Body ==== | ||
| + | |||
| + | <source lang="java"> | ||
| + | { | ||
| + | "key":"darrenwebapi", | ||
| + | "job_number":"123", | ||
| + | "parts":[ | ||
| + | { | ||
| + | "quantity":"4", | ||
| + | "external_id":"testingThis", | ||
| + | "description":"testDescription", | ||
| + | "code":"helloCode" | ||
| + | } | ||
| + | ] | ||
| + | } | ||
</source> | </source> | ||
| − | == Example curl | + | == Example Curl Requests == |
| + | |||
| + | ==== 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 http://live.mymobileworkers.com:8080/api/1/jobs/job/parts | ||
| + | |||
| + | ==== 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"}]}' http://10.1.0.87:8080/api/1/jobs/job/parts | ||
== Responses == | == Responses == | ||
Revision as of 11:09, 21 August 2013
Contents |
Summary
Job parts can only be added to a Repair/Field Service job. A job 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.
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.
Multi Part Form Data
| Create Job | ||
|---|---|---|
| URL | http://:base_url/:api_path/:version/jobs/job/parts | |
| Type | POST | |
| Params: | api_key | required |
| file | required | |
| job_number | required | |
| Response | JSON | |
JSON As Body
| Create Job - JSON | ||
|---|---|---|
| URL | http://:base_url/:api_path/:version/jobs/job/parts | |
| Type | POST | |
| JSON {key, validate_only(optional), update_existing(optional), items[]} |
required | |
| Response | JSON | |
JSON Contents
| Field | Expected Data | Required |
|---|---|---|
| name | varchar(45) | ✓ |
| code | varchar(45) | ✓ |
| quantity | double | ✓ |
| description | varchar(255) | ✓ |
| Standard Fields | ||
|---|---|---|
| Field | Expected Data | Required |
| key | string - company api key | ✓ |
| updating_existing | boolean | |
| validate_only | boolean | |
Example Input
Multi Part Form Data
{"parts":[{ "quantity":"4", "external_id":"testingThis", "description":"testDescription", "code":"helloCode" }]}
JSON As Body
{ "key":"darrenwebapi", "job_number":"123", "parts":[ { "quantity":"4", "external_id":"testingThis", "description":"testDescription", "code":"helloCode" } ] }
Example Curl Requests
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 http://live.mymobileworkers.com:8080/api/1/jobs/job/parts
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"}]}' http://10.1.0.87:8080/api/1/jobs/job/parts
Responses
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 } ] }