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:
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).
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.
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.
Figure 2
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.
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).
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).
Figure 4
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).
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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.