Difference between revisions of "Create Mobileuser"
(→JSON Contents) |
|||
| Line 69: | Line 69: | ||
|- | |- | ||
! external_id | ! external_id | ||
| − | | varchar(45) || | + | | varchar(45) || |
|- | |- | ||
! email | ! email | ||
Latest revision as of 22:21, 21 July 2017
Contents |
[edit] Summary
A mobile user 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.
The 'create mobile user' method accepts an array of mobile users to be added to the system. If the 'update_existing' parameter is set, then any existing items will be updated in the system. If set to false or not provided, then any item where the username is not unique will be rejected.
If 'validate_only' is set, the assets will only be validated but not actually inserted into the database. This can be used to check an entire dataset for errors before submitting.
The password is encrypted once received by the API, as a result it will be impossible to ever recover/receive the password back in a response. If the user is updated and you do not wish to update the password pass a null value
[edit] Multi Part Form Data
| Create Asset | ||
|---|---|---|
| URL | https://base_url/api_path/version/mobile_users | |
| Type | POST | |
| Params: | api_key | required |
| file | required | |
| update_existing | optional (default = false) | |
| validate_only | optional (default = false) | |
| Response | JSON | |
[edit] JSON As Body
| Create Job - JSON | ||
|---|---|---|
| URL | https://base_url/api_path/version/mobile_users | |
| Type | POST | |
| JSON {key, validate_only(optional), update_existing(optional), mobile_users[]} |
required | |
| Response | JSON | |
[edit] JSON Contents
| Standard Fields | ||
|---|---|---|
| Field | Expected Data | Required |
| username | varchar(32) | ✓ |
| external_id | varchar(45) | |
| varchar(127) | ||
| fullname | varchar(32) | |
| password | varchar(45) | ✓ |
| branch_id | {"name":"<branchName>"} *nested JSON object |
|
| engineer_reg_number | varchar(45) | |
| contact_number | varchar(45) | |
| 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
{ "mobile_users":[ { "username":"MrUser", "branch_id":{ "name":"Hub" }, "engineer_registration_number":"ABC", "fullname":"Bob User", "contact_number":"0192576845", "email":"MrUser@mymobileworkers.com", "password":"VerySecure" } ]}
[edit] JSON As Body
{ "key":"myApiKey", "update_existing":true, "mobile_users":[ { "username":"MrUser", "branch_id":{ "name":"Hub" }, "engineer_registration_number":"ABC", "fullname":"Bob User", "contact_number":"0192576845", "email":"MrUser@mymobileworkers.com", "password":"VerySecure" } ]}
[edit] Example Curl Requests
[edit] Multi Part Form Data
curl -F validate_only=false -F update_existing=true -F api_key=APIKEY -F file=@/Users/user/Desktop/webAPICurling/create_mobile_users.txt https://api.mymobileworkers.com:8181/api/1/mobile_users
[edit] JSON As Body
curl -X POST -H "Content-Type: application/json" -d '{"key":"myApiKey","update_existing":true,"mobile_users":[{"username":"MrUser","branch_id":{"name":"Hub"},"engineer_registration_number":"ABC","fullname":"Bob User","contact_number":"0192576845","email":"MrUser@mymobileworkers.com","password":"VerySecure"}]}' https://api.mymobileworkers.com:8181/api/1/mobile_users
[edit] Responses
[edit] Example JSON
{ "failed": [ { "name": "MrBadUser", "errors": [ { "error_code": "MBU004", "error_message": "No Password provided" } ] } ], "successful": [ { "name": "MrUser" } ] }