BookmarkSubscribeRSS Feed

Uploading Audience Data Using REST API

Started Friday by
Modified Friday by
Views 59

In my last post I used a REST API request to create an audience definition using the REST client Insomnia. In this post I'll upload audience data to this definition. This happens in a few steps:

 

  1. Create a file transfer location
  2. Upload the data to the temporary URL
  3. Upload the audience data from the temporary URL into the audience definition

 

Step 1: Create a File Transfer Location

 

To create a file transfer location, create a new HTTP request and select POST as the HTTP method. For the URL, begin with the external gateway address. In my case I used https://extapigwservice-training.ci360.sas.com/. Then add /marketing audience, the audiences endpoint, and /fileTransferLocation to the end. Your URL should look something like this:

 

https://extapigwservice-training.ci360.sas.com/marketingAudience/audiences/fileTransferLocation 

 

Under authorization add the bearer token created earlier. Refer to my last post for more information on creating a temporary token.

 

Then click Send. Insomnia will create a new temporary file transfer location (Figure 1).

 

01_MT_File_transfer_location.png

Figure 1 

 

Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.

 

 

Step 2: Upload Audience File

 

Next, you'll need to upload your audience file to your new file transfer location. To do so, create a new HTTP request and select PUT as the request. Then simply copy the file transfer location and paste it into the URL.

 

In the Body tab select File from the drop down, click Choose file and select the file to upload. After clicking Send you should receive a simple 200 OK response.

 

02_MT_Upload_Audience_File.png

 Figure 2 

 

 

Step 3: Upload Audience Data to Audience Definition

 

Your final step will be to upload the data from the file transfer location into an audience definition.

 

Create a new HTTP request and select PUT as the method.  Then input your URL from step 1. This time you'll need to locate the ID for the audience to include at the end of the URL. This can be done one of two ways.

 

  1. Navigate to the Audience Definitions page under General Settings in the CI360 user interface and click on your desired definition. The ID will appear at the top.
  2. Open your previous call to create the audience definition in Insomnia and retrieve the audience ID from the results preview.

 

After adding your audience definition ID, end the URL with/data. Your URL should look something like this:

 

https://extapigwservice-training.ci360.sas.com/marketingAudience/audiences/dc1f8fed-de7e-4de8-b9a2-d7c82b5cdb00/data 

 

Next, you'll need the sample json for uploading an audience file from the Audiences API documentation in support.sas.com.

 

The sample will look something like this:

 

{

“audienceId”: “asfsaf-wer234-ce4asfd234234”,

“name”:”My New Audience Definition”,

“fileLocation”: “https://server/transfers”,

“headerRowIncluded”: true

}

 

Back in Insomnia, in the Body tab, select JSON and paste the sample code. Input a new name, the audience ID, and the temporary file location in their corresponding lines. If your file includes a header row leave Header row included as true (Figure 3).

 

03_MT_Audience_Data_Upload.png

 Figure 3 

 

Under authorizations, add your bearer token. Then click Send. You should receive a status of file submitted and status description of running (Figure 4).

 

04_MT_Audience_Upload_Running.png

 Figure 4 

 

 

Checking Upload Status

 

Now that your audience data upload is running, you may continue to use Insomnia to check the status of your upload. To do so, create a duplicate of this request and change the method to GET. In the URL remove data and replace it with history and the history id found in your previous request. The URL should look something like this:

 

https://extapigwservice-training.ci360.sas.com/marketingAudience/audiences/dc1f8fed-de7e-4de8-b9a2-d7c82b5cdb00/history/9ce9550d-da69-4d13-a409-446e8f7a09bc 

 

After clicking Send the results should indicate the status of your data upload (Figure 5).

 

05_MT_Audience_Upload_Complete.png

 Figure 5 

 

If you’d like to learn more about creating an audience definition using the user interface, please see the course titled SAS 360 Audiences in the SAS Customer Intelligence 360 Learning Subscription. Or if you’d like to learn more about REST API’s please see the course titled Managing Users, Settings, Content Delivery, and REST APIs in SAS Customer Intelligence 360 in the Customer Intelligence 360 learning subscription or the Customer Intelligence 360 Admin Guide.

 

 

 

Find more articles from SAS Global Enablement and Learning here.

Contributors
Version history
Last update:
Friday
Updated by:

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

SAS AI and Machine Learning Courses

The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.

Get started

Article Tags