Difference between revisions of "Update Custom List"

From MyMobileWorkers API
Jump to: navigation, search
(→‎JSON As Body)
(→‎JSON Contents)
 
(8 intermediate revisions by 2 users not shown)
Line 24: Line 24:
 
| colspan="2" | JSON
 
| colspan="2" | JSON
 
|}
 
|}
−
 
  
 
==== JSON As Body ====
 
==== JSON As Body ====
Line 38: Line 37:
 
|-
 
|-
 
!  
 
!  
−
|  {key}   ||| required     
+
|  key  ||| required     
 
|-
 
|-
 
|-
 
|-
 
!  
 
!  
−
| {branch}   ||| optional     
+
| branch_name   ||| optional     
 
|-
 
|-
 
|-
 
|-
 
!  
 
!  
−
| {list}   ||| required     
+
| list (object)   ||| required     
 
|-
 
|-
 
!  
 
!  
−
| {list}  ||| required     
+
| {list object} name   ||| required     
 
|-
 
|-
 
!  
 
!  
−
| {list}   ||| required    
+
| {list object} description ||| optional    
 
|-
 
|-
 
!  
 
!  
−
| {list}  ||| required     
+
| {list object} list_key  ||| required   
 +
|-
 +
!
 +
| {list object} items   ||| required     
 
|-
 
|-
 
! Response
 
! Response
 
| colspan="2" | JSON
 
| colspan="2" | JSON
 +
|}
 +
 +
{| border="1" class="wikitable"
 +
|+ List Item (nested) object:
 +
 +
! colspan="3" | Standard Fields
 +
|-
 +
! Field
 +
! Expected Data
 +
! Required
 +
|-
 +
! name
 +
| varchar(255) || ✓
 +
|-
 +
! notes
 +
| varchar(255) ||
 +
|-
 +
! order_position
 +
| int(11) ||
 +
|-
 +
! external_id
 +
| varchar(255) ||
 +
|-
 +
! triggers
 +
| varchar(255) ||
 +
|-
 
|}
 
|}
  
Line 75: Line 103:
 
             "name":"Aldcliffe Site",
 
             "name":"Aldcliffe Site",
 
             "notes":"small",
 
             "notes":"small",
−
             "order_position":5
+
             "order_position":5,
 +
            "triggers": "photo,fail,note"
 
         },
 
         },
 
         {   
 
         {   
 
             "name":"Bond Estate",
 
             "name":"Bond Estate",
 
             "notes":"medium",
 
             "notes":"medium",
−
             "order_position":6
+
             "order_position":6,
 +
            "triggers": "photo"
 
         }
 
         }
 
       ]
 
       ]

Latest revision as of 11:37, 12 March 2018

Contents

[edit] Summary

The Update Custom List API call allows an existing list to be updated with a new name, description and list items by giving the list key within the request. When updating the list, it will delete any existing items in the custom list and replace with the items provided in the response.

A custom list can be updated via two different methods - either as multi-part form data, or as JSON content on its own, with the API key supplied within the JSON.

[edit] Multi Part Form Data

Update Customer Name
URL http://base_url/api_path/version/lists/edit
Type POST
Params: key required
Response JSON

[edit] JSON As Body

Create Job - JSON
URL http://base_url/api_path/version/list/edit
Type POST
key required
branch_name optional
list (object) required
{list object} name required
{list object} description optional
{list object} list_key required
{list object} items required
Response JSON
List Item (nested) object:
Standard Fields
Field Expected Data Required
name varchar(255) ✓
notes varchar(255)
order_position int(11)
external_id varchar(255)
triggers varchar(255)

[edit] JSON Contents

{
   "key":"APIKEY",
   "branch_name":"BranchA",
   "list":{  
      "name":"Delivery sites",
      "description":"A list of delivery sites in the area",
      "list_key":"delivery_site1",
      "list_items":[  
         {  
            "name":"Aldcliffe Site",
            "notes":"small",
            "order_position":5,
            "triggers": "photo,fail,note"
         },
         {  
            "name":"Bond Estate",
            "notes":"medium",
            "order_position":6,
            "triggers": "photo"
         }
      ]
   }
}

[edit] Example Curl Request

[edit] Multi Part Form Data

curl -F api_key=YOUR_KEY http://api.mymobileworkers.com:8080/api/1/lists/edit

[edit] JSON As Body

curl -X POST -H "Content-Type: application/json" -d '{"key":"YOUR_KEY"}' http://api.mymobileworkers.com:8080/api/1/lists/edit

[edit] Responses

[edit] Successful

{
  "successful": {
    "list_name": "Delivery sites",
    "branch_name": null
  }
}

[edit] Unsuccessful

{"error_code": "LIS002", "error_message": "List not found."}
{"error_code": "LIS001", "error_message": "List key not provided. Please include in request."}
{ "error_code": "LIS004", "error_message": "No items were provided."}
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox