- Print
- DarkLight
- PDF
Article summary
Did you find this summary helpful?    
Thank you for your feedback!
Description
Adds a new collection or updates an existing collection of the same name with the fields and data items provided. Accepts same data formats as Collection.AddItem bulk insertion. Your app should make a POST request to the request URL, passing the JSON or XML file as part of a standard form-encoded post body.
URL parameters
| Name | Required | Type | Description | 
|---|---|---|---|
| Name | True | string | Name of the new or updated collection. | 
Request body
Accepts same data formats as Collection.AddItem bulk insertion. The fields and values of the rows you want to add in bulk. You can format these in XML or in JSON.
XML
| Name | Required | Type | Description | 
|---|---|---|---|
| File | True | XML | A file containing the items, fields, and values of the data to be added. POSTusing Content-Typemultipart/form-data. | 
<ItemList>
	<Item>
		<Field1>Value1</Field1>
		<Field2>Value2</Field2>
	</Item>
	<Item>
		<Field1>Value3</Field1>
		<Field2>Value4</Field2>
	</Item>
</ItemList>
JSON
| Name | Required | Type | Description | 
|---|---|---|---|
| POSTDATA | True | JSON | JSON array of objects with fields and values of the data to be added. POSTusing Content-Typeapplication/x-www-form-urlencoded. | 
[
  { "Field1": "Value1", "Field2": "Value2" },
  { "Field1": "Value3", "Field2": "Value4" }
]
Responses
| Name | Type | Description | 
|---|---|---|
| Result | string | Successif the operation was successful. | 
| CollectionID | numeric | Unique identifier for the new or updated collection. | 
| CollectionName | string | Name for the new or updated collection. | 
| CollectionAdded | boolean | Whether or not a new collection was added. | 
| FieldsAdded | numeric | Total fields added. | 
| ItemsAdded | numeric | Total items added. | 
Sample requests
XML
curl -X POST "https://api.mozenda.com/rest?WebServiceKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&Service=Mozenda10&Operation=Collection.AddUpdate&Name=MyUpdatedCollection" \ 
-F "file=@/path/to/file.xml"
JSON
curl -X POST "https://api.mozenda.com/rest?WebServiceKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&Service=Mozenda10&Operation=Collection.AddUpdate&Name=MyUpdatedCollection" \ 
-d '[{"Field1": 1, "Field2": 2}, {"Field1": 3, "Field2": 4}]'
Sample responses
XML
<?xml version="1.0" encoding="utf-8" ?>
<CollectionAddUpdateResponse
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<Result>Success</Result>
	<CollectionID>1201</CollectionID>
	<CollectionName>AddUpdateCollectionJSON</CollectionName>
	<CollectionAdded>True</CollectionAdded>
	<FieldsAdded>3</FieldsAdded>
	<ItemsAdded>8</ItemsAdded>
</CollectionAddUpdateResponse>
JSON (add &ResponseFormat=JSON)
{
  "CollectionID": 5356,
  "CollectionName": "testapi",
  "CollectionAdded": false,
  "FieldsAdded": 0,
  "ItemsAdded": 2,
  "JsonResult": {
    "Command": "Collection.AddUpdate",
    "AutoLoggedIn": false,
    "WebConsoleKey": "",
    "Result": "Success",
    "ErrorCode": "",
    "ErrorDescription": "",
    "ErrorList": [],
    "ExecutionTime": {
      "Ticks": 0,
      "Days": 0,
      "Hours": 0,
      "Milliseconds": 0,
      "Minutes": 0,
      "Seconds": 0,
      "TotalDays": 0,
      "TotalHours": 0,
      "TotalMilliseconds": 0,
      "TotalMinutes": 0,
      "TotalSeconds": 0
    }
  }
}
Was this article helpful?
