Difference between revisions of "Create Custom List Item"

From MyMobileWorkers API
Jump to: navigation, search
(→‎JSON As Body)
 
(5 intermediate revisions by 2 users not shown)
Line 59: Line 59:
 
|-
 
|-
 
! list_key
 
! list_key
−
| float(10,2) || ✓
+
| varchar(255) ||  
 
|-
 
|-
 
! name
 
! name
−
| float(10,2) || ✓
+
| varchar(255) || ✓
 
|-  
 
|-  
 
! notes
 
! notes
Line 68: Line 68:
 
|-
 
|-
 
! order_position
 
! order_position
−
| text ||
+
| int(11) ||
 
|-   
 
|-   
 
! external_id
 
! external_id
−
| varchar(45) ||  
+
| varchar(255) ||
 +
|-
 +
! triggers
 +
| varchar(255) ||  
 
|-  
 
|-  
 
|}
 
|}
Line 90: Line 93:
 
|-  
 
|-  
 
|}
 
|}
 +
 +
== Example Input ==
 +
 +
==== Multi Part Form Data ====
 +
 +
<source lang="java">
 +
{"items":[{
 +
"external_id":"ss303",
 +
"name":"Rolfe Centre",
 +
"notes":"Medium size",
 +
"list_key":"site_list",
 +
"order_position": 1,
 +
"triggers": "photo,fail,note"
 +
}]}
 +
</source>
 +
 +
==== JSON As Body ====
 +
 +
<source lang="java">
 +
{
 +
  "key":"darrenwebapi",
 +
  "update_existing":true,
 +
  "items":[
 +
      {
 +
        "external_id":"ss303",
 +
"name":"Rolfe Centre",
 +
"notes":"Medium size",
 +
"list_key":"site_list",
 +
"order_position": 1,
 +
"triggers": "fail,note"
 +
      }
 +
  ]
 +
}
 +
</source>
 +
 +
== Example Curl Requests ==
 +
 +
==== Multi Part Form Data ====
 +
 +
curl  -F update_existing=true -F api_key=darrenwebapi -F
 +
file=@/Users/darrenatherton/Desktop/webAPICurling/create_item.txt https://api.mymobileworkers.com:8181/api/1/list/item/create
 +
 +
==== JSON As Body ====
 +
 +
curl -X POST -H "Content-Type: application/json" -d '{"key":"darrenwebapi","update_existing":true,"items":[{"external_id":"ss303","name":"Rolfe Centre","notes":"Medium size","list_key":"site_list","order_position":1,"triggers": "photo,fail,note"}]} https://api.mymobileworkers.com:8181/api/1/list/item/create
 +
 +
== Responses ==
 +
 +
=== Example JSON ===
 +
 +
<source lang="java">
 +
{
 +
  "failed": [],
 +
  "successful": [
 +
    {
 +
      "item_name": "Rolfe Centre"
 +
    }
 +
  ]
 +
}
 +
</source>

Latest revision as of 11:39, 12 March 2018

Contents

[edit] Summary

A list item 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 item' method accepts an array of list items to be added to the system. If the 'update_existing' parameter is set, then any existing list items will be updated in the system. If set to false or not provided..

[edit] Multi Part Form Data

Create Item
URL http://base_url/api_path/version/list/item/create
Type POST
Params: api_key required
file required
update_existing optional (default = false)
Response JSON

[edit] JSON As Body

Create Item - JSON
URL https://base_url/api_path/version/list/item/create
Type POST
JSON
{key, update_existing(optional), items[]}
required
Response JSON

[edit] JSON Contents

The JSON file is passed in the post as the "file"
Standard Fields
Field Expected Data Required
list_key varchar(255)
name varchar(255) ✓
notes text
order_position int(11)
external_id varchar(255)
triggers varchar(255)
Fields exclusive to JSON body format:
Standard Fields
Field Expected Data Required
key string - company api key ✓
update_existing boolean

[edit] Example Input

[edit] Multi Part Form Data

{"items":[{
"external_id":"ss303",
"name":"Rolfe Centre",
"notes":"Medium size",
"list_key":"site_list",
"order_position": 1,
"triggers": "photo,fail,note"
}]}

[edit] JSON As Body

{
   "key":"darrenwebapi",
   "update_existing":true,
   "items":[
      {
        "external_id":"ss303",
"name":"Rolfe Centre",
"notes":"Medium size",
"list_key":"site_list",
"order_position": 1,
"triggers": "fail,note"
      }
   ]
}

[edit] Example Curl Requests

[edit] Multi Part Form Data

curl -F update_existing=true -F api_key=darrenwebapi -F file=@/Users/darrenatherton/Desktop/webAPICurling/create_item.txt https://api.mymobileworkers.com:8181/api/1/list/item/create

[edit] JSON As Body

curl -X POST -H "Content-Type: application/json" -d '{"key":"darrenwebapi","update_existing":true,"items":[{"external_id":"ss303","name":"Rolfe Centre","notes":"Medium size","list_key":"site_list","order_position":1,"triggers": "photo,fail,note"}]} https://api.mymobileworkers.com:8181/api/1/list/item/create

[edit] Responses

[edit] Example JSON

{
  "failed": [],
  "successful": [
    {
      "item_name": "Rolfe Centre"
    }
  ]
}
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox