Difference between revisions of "Create Assets"

From MyMobileWorkers API
Jump to: navigation, search
(→‎Summary)
Line 35: Line 35:
  
 
== JSON Parameters ==
 
== JSON Parameters ==
 +
 +
{| border="1" class="wikitable"
 +
|+ The JSON file is passed in the post as the "file"
 +
! colspan="3" | Standard Fields
 +
|-
 +
! Field
 +
! Expected Data
 +
! Required
 +
|-
 +
! external_id
 +
| varchar(45) ||
 +
|-
 +
! item_id
 +
| {"name":"<itemName>"} <br /><span style="font-size:80%; font-weight:normal">*nested JSON object</span>|| &#10003;
 +
|-
 +
! serial_number
 +
| varchar(45) <br /><span style="font-size:80%; font-weight:normal">* must be unique</span>|| &#10003;
 +
|-
 +
! description
 +
| varchar(255) ||
 +
|- 
 +
! location
 +
| varchar(45) ||
 +
|-
 +
! job_id
 +
| {"job_number":"<jobNumber>"} <br /><span style="font-size:80%; font-weight:normal">*nested JSON object</span>||
 +
|-
 +
! customer_id
 +
| {"name":"<customerName>"} <br /><span style="font-size:80%; font-weight:normal">*nested JSON object</span>||
 +
|-
 +
! status_id
 +
| {"status":"<statusName>"} <br /><span style="font-size:80%; font-weight:normal">*nested JSON object</span>|| &#10003;
 +
|-
 +
! custom_fields
 +
| JSON ||
 +
|-
 +
|}
  
 
== Example JSON ==
 
== Example JSON ==

Revision as of 12:26, 6 August 2013

Contents

Summary

Create Asset
URL http://base_url/api_path/version/assets
Type POST
Params: api_key required
file required
update_existing optional (default = false)
validate_only optional (default = false)
Response JSON


The 'create asset' method accepts an array of assets to be added to the system. If the 'update_existing' parameter is set, then any existing assets will be updated in the system. If set to false or not provided, then any asset where the serial number is not unique will be rejected.

When an asset is created or updated, a new asset history entry is also created in the system to keep track of the asset over time.

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.

JSON Parameters

The JSON file is passed in the post as the "file"
Standard Fields
Field Expected Data Required
external_id varchar(45)
item_id {"name":"<itemName>"}
*nested JSON object
✓
serial_number varchar(45)
* must be unique
✓
description varchar(255)
location varchar(45)
job_id {"job_number":"<jobNumber>"}
*nested JSON object
customer_id {"name":"<customerName>"}
*nested JSON object
status_id {"status":"<statusName>"}
*nested JSON object
✓
custom_fields JSON

Example JSON

{"assets":[{
"external_id":"sss32",
"item_id":{"name":"Woo"},
"serial_number":"serialNo123",
"description":"describingwords",
"location":"aPlace",
"job_id":{"job_number":"123"},
"customer_id":{"name":"john"},
"status_id":{"status":"test"}
}]}

Example curl request

curl -F validate_only=false -F update_existing=true -F api_key=darren_web_api -F file=@/Users/user/Desktop/webAPICurling/create_asset.txt http://live.mymobileworkers.com:8080/api/1/assets

Responses

Example JSON

{
	"successful":
	[
		{"serial_number":"S0103"},
		{"serial_number":"S0245"}
	],
	"failed":
	[
		{
			"serial_number":"S0384",
			"errors": 
			[
				{
					"error_code":"ASV012",
					"error_msg":"Status id cannot be null."
				}
			]
		}
	]
}
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox