--- title: "Collection.AddItem - Web Scraping API - Mozenda" slug: "collectionadditem" description: "Use Collection.AddItem to add an item to an existing collection with values specified. " updated: 2024-05-14T14:22:13Z published: 2024-05-14T14:22:13Z canonical: "help.mozenda.com/collectionadditem" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.mozenda.com/llms.txt > Use this file to discover all available pages before exploring further. # Collection.AddItem ### Description Adds an **item** to a **collection** with the values specified. It is also possible to add **items** in bulk by attaching XML or JSON to the request. This option should be used whenever a large number of **items** needs to be inserted all at once. ### URL parameters URL parameter ordering The **URL parameters** below are listed in the order they should be entered in the API **URL**. | Name | Required | Type | Description | | --- | --- | --- | --- | | `CollectionID` | True | numeric | Unique identifier for the new **collection**. | | `Field.<FieldName>` | False | string | **Field** name and its value. | ### Request body (optional) 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` | False | XML | A **file** containing the **items**, **fields**, and values of the data to be added. `POST` using Content-Type `multipart/form-data`. | ``` Value1 Value2 Value3 Value4 ``` #### JSON | Name | Required | Type | Description | | --- | --- | --- | --- | | `POSTDATA` | False | JSON | JSON array of **objects** with **fields** and values of the data to be added. `POST` using Content-Type `application/x-www-form-urlencoded`. | ``` [ { "Field1": "Value1", "Field2": "Value2" }, { "Field1": "Value3", "Field2": "Value4" } ] ``` ### Responses | Name | Type | Description | | --- | --- | --- | | `Result` | string | `Success` if the operation was successful. | | `ItemID` | numeric | Unique identifier of the new **item** (returned only when using the `GET`method to add a single row). | ### Sample requests #### `GET` with fields and values specified in the URL ``` curl -X GET 'https://api.mozenda.com/rest?WebServiceKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&Service=Mozenda10&Operation=Collection.AddItem&CollectionID=1001&Field.FirstName=John&Field.LastName=Smith' ``` #### `POST` - XML body ``` curl -X POST 'https://api.mozenda.com/rest?WebServiceKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&Service=Mozenda10&Operation=Collection.AddItem&CollectionID=1001' -F 'file=@/path/to/file.xml' ``` #### `POST` - JSON body ``` curl -X POST 'https://api.mozenda.com/rest?WebServiceKey=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&Service=Mozenda10&Operation=Collection.AddItem&CollectionID=1001' -d '[{"Field1": "Value1", "Field2": "Value2"}, {"Field1":"Value11", "Field2": "Value22"}]' ``` ### Sample responses #### XML ``` Success 1098 ``` #### JSON (add `&ResponseFormat=JSON`) ``` { "JsonResult": { "Command": "Collection.AddItem", "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 } } } ```