ReachMail API - Part II - uploading a list

Follow

There are three distinct processes in the uploading of a new list to your ReachMail account via the API.  If you already have a list in the ReachMail system, you can either skip part a below or retrieve your list GUID from the query to /lists/filtered/{AccountId}

a. creating the list
b. uploading the file
c. import data from the file into the list.

a. creating the list:

The first step is to POST to /lists/{AccountId} (/lists/00000000-0000-0000-0000-000000000000)

{
  "Name": "test list",
  "Type": "Recipient",
  "GroupId": "00000000-0000-0000-0000-000000000000",
  "Fields": [...]
}

The response to this call will return an id (list GUID) like:

{
  "Id": "00000000-0000-0000-0000-000000000000"
}

store this ID for use in the third step.

b. uploading the file requires a POST to /data

The second step is uploading the file via data stream with the following JSON:

{
  "Input": {...}
}

The response to this call is another id, the data id GUID:

{
  "Id": "00000000-0000-0000-0000-000000000000"
}

c. Importing the data from the file to the list. This third and final step is the bridge between the first two steps. 

This step requires the POST to /lists/import/{AccountId}/{ListId}.  Remember the accountId is the account GUID, and the ListId is the GUID returned from the POST to /lists/{AccountId}.  The body of the query also references the DataId GUID returned from the call in part b. 

Here's the sample JSON:

{
  "DataId": "00000000-0000-0000-0000-000000000000",
  "FieldMappings": [{
      "DestinationFieldName": "",
      "SourceFieldPosition": 0,
      "SourceFieldName": ""
      }],
  "ImportOptions": {
      "Format": "CharacterSeperated",
      "HeaderRow": false,
      "SkipRecordsWithErrors": false,
      "AllowStringTruncation": false,
      "AbortImportOnError": false,
      "CharacterSeperatedOptions": {
          "Delimiter": "Comma"
      },
      "ExcelOptions": {
         "WorksheetName": ""
      }
   }
}

The documentation page will have more information as to which fields are required and which are optional.  See more here.

Have more questions? Submit a request

Comments