Difference between revisions of "Create Jobs"
From MyMobileWorkers API
(→JSON Parameters) |
|||
| Line 150: | Line 150: | ||
=== Example JSON === | === Example JSON === | ||
| + | |||
| + | ==== test ==== | ||
<source lang="java"> | <source lang="java"> | ||
Revision as of 09:15, 16 August 2013
Contents |
Summary
| Create Job | ||
|---|---|---|
| URL | http://base_url/api_path/version/jobs | |
| Type | POST | |
| Params: | api_key | required |
| file | required | |
| update_existing | optional (default = false) | |
| validate_only | optional (default = false) | |
| Response | JSON | |
The create job method accepts an array of jobs to be added to the system. If the update_existing param is set then any existing jobs will be updated in the system, if set to false or not provided then any job where the job number is not unique will be rejected.
If validate_only is set the jobs will only be validated but not actually inserted. This can be used to check an entire dataset for errors before submitting.
JSON Parameters
| Standard Fields | ||
|---|---|---|
| Field | Expected Data | Required |
| job_number | varchar(45) * must be unique |
✓ |
| address_1 | varchar(45) | ✓ |
| address_2 | varchar(45) | |
| address_3 | varchar(45) | |
| address_4 | varchar(45) | |
| postcode | varchar(45) | ✓ |
| contact_name | varchar(45) | ✓ |
| contact_number_1 | varchar(45) | ✓ |
| contact_number_2 | varchar(45) | |
| timeslot | datetime | ✓ |
| special_instructions | text | |
| type (type of job) |
"repair","podc","gassafe" | ✓ |
| mobile_user | {"username":"<username>"} *nested JSON object |
✓ |
| customer | {"name":"<customer name>"} *nested JSON object |
|
| product | varchar(255) | |
| fault | varchar(255) | |
| Gas Safe Only Fields | ||
| owner_title | varchar(45) | |
| owner_name | varchar(45) | ✓ |
| owner_address_1 | varchar(45) | ✓ |
| owner_address_2 | varchar(45) | |
| owner_address_3 | varchar(45) | |
| owner_address_4 | varchar(45) | |
| owner_postcode | varchar(45) | ✓ |
| owner_contact_number | varchar(45) | |
| owner_email | varchar(255) | |
| customer_email | varchar(255) | |
Example JSON
{"jobs":[{ "job_number":"SEJOB9", "address_1":"Rover Lane", "address_2":"Glasgow", "contact_name":"Joe Bloggs", "contact_number_1":"0770999999", "contact_number_2":"", "mobile_user":{"username":"MOB_01"}, "customer":{"name":"Momote"}, "postcode":"G71 8TS","type":"repair", "timeslot":"2013-04-09 17:54:39", "special_instructions":"Door bell is faulty so knock on the door", "repair_description":"Replace U Bend" }]}
Example curl request
curl -F validate_only=false -F update_existing=true -F api_key=lee_test -F file=@/Users/user/Desktop/webAPICurling/create_job.txt http://live.mymobileworkers.com:8080/api/1/jobs
Responses
Example JSON
test
{ "successful": [ {"job_number":"A0103"}, {"job_number":"A0245"} ], "failed": [ { "job_number":"A0384", "errors": [ { "error_code":"WAJ003", "error_msg":"Job number already exists." } ] } ] }