Create Items
From MyMobileWorkers API
Revision as of 11:04, 8 August 2013 by Darren.atherton (Talk | contribs)
Contents |
Summary
| Create Item | ||
|---|---|---|
| URL | http://base_url/api_path/version/items | |
| Type | POST | |
| Params: | api_key | required |
| file | required | |
| update_existing | optional (default = false) | |
| validate_only | optional (default = false) | |
| Response | JSON | |
The 'create item' method accepts an array of items 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 item 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) | |
| category_id | {"name":"<categoryName>"} *nested JSON object |
|
| name | varchar(255) * must be unique |
✓ |
| notes | text | |
| product_code | varchar(45) | |
| price | float(10,2) | |
Example JSON
{"items":[{ "external_id":"ss303", "category_id":{"name":"Test1"}, "name":"darrenItem", "notes":"notesnotesnotesnotesnotesnotesnotesnotesnotesnotesnotes", "product_code":"productCodeTest", "price":"2.50" }]}
Example curl request
curl -F validate_only=false -F update_existing=true -F api_key=darrenwebapi -F file=@/Users/darrenatherton/Desktop/webAPICurling/create_item.txt http://live.mymobileworkers.com:8080/api/1/items
Responses
Example JSON
{ "successful": [ {"item_name":"testItem"}, {"item_name":"testItem2"} ], "failed": [ { "item_name":"testItem3", "errors": [ { "error_code":"ITE012", "error_msg":"name cannot be null." } ] } ] }