Create Category
From MyMobileWorkers API
Revision as of 10:23, 12 August 2013 by Darren.atherton (Talk | contribs)
Contents |
Summary
| Create Category | ||
|---|---|---|
| URL | http://base_url/api_path/version/categories | |
| Type | POST | |
| Params: | api_key | required |
| file | required | |
| update_existing | optional (default = false) | |
| validate_only | optional (default = false) | |
| Response | JSON | |
The 'create category' method accepts an array of categories to be added to the system. If the 'update_existing' parameter is set, then any existing categories will be updated in the system. If set to false or not provided, then any category where the category name is not unique will be rejected.
If 'validate_only' is set, the items will only be validated but not actually inserted into the database. This can be used to check an entire dataset for errors before submitting.
JSON Parameters
| Standard Fields | ||
|---|---|---|
| Field | Expected Data | Required |
| external_id | varchar(45) | |
| name | varchar(255) * must be unique |
✓ |
Example JSON
{"categories":[{ "external_id":"ss304", "name":"exampleCategory" }]}
Example curl request
curl -F validate_only=false -F update_existing=true -F api_key=darrenwebapi -F file=@/Users/darrenatherton/Desktop/webAPICurling/create_category.txt http://live.mymobileworkers.com:8080/api/1/categories
Responses
Example JSON
{ "successful": [ {"name":"testCategory1"}, {"name":"testCategory2"} ], "failed": [ { "item_name":"testCategory3", "errors": [ { "error_code":"CVA012", "error_msg":"name cannot be null." } ] } ] }