Create a new list
1 |
POST /api/1/list |
Parameters
Name | Parameter Type |
Allow Multiple |
Required/ Optional |
Data Type | Description |
---|---|---|---|---|---|
Authorization: | Header | false | required | String (Bearer {access token}) | Pass the authentication token that was granted when you authorized access. |
listname | form | false | required | string | The list name to display in the UI. |
foldername | form | false | optional | string | Name of folder that contains the list. If left blank, the list goes into the Default Folder. If the folder does not exist it will be created. |
headings | form | false | Optional | String | "Y" or "N" for if the first row of the file are headings. Default value is "Y". Any non-null value other than "Y" will be treated as "N". |
fieldseparator | form | false | Optional | String ("COMMA", "TAB", "SEMI") | Character used around fields--valid values: "COMMA", "TAB", "SEMI". If not specified then the field separator value is determined by inspecting the file upload data. |
uploadspecs | form | false | required | String | When creating a new list, uploadSpecs is used to describe the structure of the list you are creating in Act-On.* |
file | Body | false | optional | File | The file to upload (in CSV format). |
quotecharacter | form | false | required | String ("NONE", "SINGLE_QUOTE", "DOUBLE_QUOTE") | Specify the type of quotes used around field names. Valid values: "NONE", "SINGLE_QUOTE", "DOUBLE_QUOTE" |
*Note: See uploadspecs
Request
Following are example requests:
HTTP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
POST /api/1/list HTTP/1.1 Host: restapi.actonsoftware.com Authorization: Bearer 781137c426b2db9fb0fe137fb6ffde79 Cache-Control: no-cache Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ----WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="listname" New List ----WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="foldername" New Folder ----WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="headings" Y ----WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="fieldseperator" COMMA ----WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="quotecharacter" DOUBLE_QUOTE ----WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="uploadspecs" [{"columnHeading": "E-mail Address", "ignoreColumn": "N", "columnType": "EMAIL", "columnIndex": "0"}, {"columnHeading": "First Name", "ignoreColumn": "N", "columnType": "FIRSTNAME", "columnIndex": "1"}, {"columnHeading": "Last Name", "ignoreColumn": "N", "columnType": "LASTNAME", "columnIndex": "2"},{"columnHeading": "Company", "ignoreColumn": "N", "columnType": "COMPANY", "columnIndex": "3"}] ----WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="file"; filename="API Test Upload.csv" Content-Type: application/vnd.ms-excel ----WebKitFormBoundary7MA4YWxkTrZu0gW |
curl
1 |
curl -X POST -H 'Authorization: Bearer 863d23455dfb499ded19d17d5af19fc4' -H 'Cache-Control: no-cache' -H 'Content-Type: multipart/form-data' -F 'listname=Test List' -F 'headings=Y' -F 'fieldseperator=COMMA' -F 'quotecharacter=NONE' -F 'uploadspecs=[{"columnHeading": "E-mail Address", "ignoreColumn": "N", "columnType": "EMAIL", "columnIndex": "0"}, {"columnHeading": "First Name", "ignoreColumn": "N", "columnType": "FIRSTNAME", "columnIndex": "1"}, {"columnHeading": "Last Name", "ignoreColumn": "N", "columnType": "LASTNAME", "columnIndex": "2"},{"columnHeading": "Company", "ignoreColumn": "N", "columnType": "COMPANY", "columnIndex": "3"}]' -F 'file=@/path/to/file.csv' 'https://restapi.actonsoftware.com/api/1/list' |
Response
A successful request results in an HTTP 200 response with a JSON object with the list listing.
An example JSON response:
1 2 3 4 5 |
{ "status": "success", "message": "Upload completed", "jobId": "8167376" } |
When you use a file upload to create a list, the job id is returned. To get the upload status, send a request using this job id:
1 |
GET /api/1/list/{jobid}/status |
This returns a JSON object similar to the following. If the list was uploaded successfully, the list id is returned along with the number of appended, updated, failed and rejected records.
1 2 3 4 |
{ status: "success" jobDetails: "{"status":"ok","listId":"l-7662","appendCount":4,"updateCount":0,"failedCount":0,"rejectedCount":0}" } |
If you do not include a file in your POST request, an empty list is created and the list id is returned.
1 2 3 4 5 |
{ "listId": "l-0c87", "status": "success", "message": "List created" } |
Code Examples
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import requests url="https://restapi.actonsoftware.com/api/1/list" headers = { 'Authorization': "Bearer 79d2b5f77ed964ba7ea2b8e43efdda8", 'cache-control': "no-cache" } # This describes the column headings that the CSV file is mapped. # In this case, Email, Second Column, Third Column data = { 'listname':'API Email Example List', 'uploadspecs':'[{"columnHeading":"Email","ignoreColumn":"N","columnType":"EMAIL","columnIndex":"0"},n{"columnHeading":"SECOND COLUMN","ignoreColumn":"N","columnIndex":"1"},n{"columnHeading":"THIRD COLUMN","ignoreColumn":"N","columnIndex":"2"}]', 'quotecharacter':'NONE', 'fieldseparator':'COMMA' } # Import.csv is a csv file with email, and two additional columns of data files = {'file':('Imported.csv', open('Imported.csv', 'rb'))} r = requests.post(url, data=data, headers=headers, files=files) print(r.content) |