Create Assets

From MyMobileWorkers API
Revision as of 16:40, 5 April 2020 by Ian (Talk | contribs)

Jump to: navigation, search

Contents

Summary

An asset 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 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 As Body

Create Job Tracking Reference - JSON
URL https://base_url/api_path/version/jobs/trackingref/update
Type POST
JSON
{key, validate_only(optional), update_existing(optional), jobs_trackingrefs[]}
required
Response JSON

JSON Contents

The JSON file is passed in the post as the "file"
Standard Fields
Field Expected Data Required
jobId {"job_number":"<job_number>"}
*nested JSON object
✓
Fields exclusive to JSON body format:
Standard Fields
Field Expected Data Required
key string - company api key ✓
update_existing boolean
validate_only boolean

Example Input

JSON As Body

{
   "key":"api_key",
   "update_existing":"true",
   "validate_only":"false",
   "jobs_trackingrefs":[
      {
         "jobId" : {
         	"job_number":"test_number"
         }
      }
   ]
}

Example Curl Requests

JSON As Body

curl -X POST -H "Content-Type: application/json" -d '{

  "key":"api_key",
     "update_existing":"true",
     "validate_only":"false",
     "jobs_trackingrefs":[
        {
           "jobId" : {
           	"job_number":"test_number"
           }
        }
     ]

}' https://api.mymobileworkers.com:8181/api/1/jobs/trackingref/update

Responses

Example JSON

{
    "failed": [],
    "successful": [
        {
            "job_number": "test_number",
            "tracking_ref": "test_tracking_ref"
        }
    ]
}
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox