You are an operation manager in a marketing services organization. At a regular interval, you need to tweet the marketing content for your multiple clients. Instead of accessing Twitter account for each client every time, you can use Data Integration REST API Connector to call the Twitter Update API.
To make a POST request to a REST API, you configure the payload required by the API when you create a task. The Twitter Update API does not require a payload. Therefore, in this example, you configure the text to be tweeted in Field Mapping without configuring a payload. This example does not parse the response of the POST request.
Perform the following steps:
1Create a REST API Connection to use as a target.
2Create and run a synchronization task.
Create a Connection
1On the Connections page, click New Connection.
2Specify the following details:
Connection Property
Description
Connection Name
Enter a unique name for the connection.
Description
Provide a relevant description for the connection.
Type
Select ReST from the list.
Runtime Environment
Select the appropriate secure agent from the list.
Base URL
Enter https://api.twitter.com/1.1/statuses/update.json
Url Request Parameters
status=TestTweet
Media Type
Select application/json
Request Type
Select POST
Authentication Type
Select OAUTH
OAuth Consumer Key
Provide Oauth consumer key for your Twitter account.
OAuth Consumer Secret
Provide Oauth consumer secret key for your Twitter account.
OAuth Token
Provide Oauth token for your Twitter account.
OAuth Token Secret
Provide OAuth token secret for your Twitter account.
Create the config csv file
Select No
The following image shows the sample values:
3Click Save to save the connection.
Create a Synchronization Task
For POST request, configure the REST API connection as target.
Before you create a synchronization task, create a flat file and save the text that you want to tweet. For example, TwitterStatus.txt. Create a flat file connection to use as a source.
1Click New > Tasks.
2Select Synchronization Task and click Create.
3In the New Synchronization Task page, configure the following fields:
Field
Description
Task Name
Name of the synchronization task. For example: REST_TwitterUpdate
Description
Description of the synchronization task. Maximum length is 255 characters.
Task Operation
Select Insert.
4Click Next.
5On the Source page, configure the following fields:
Field
Description
Connection
Select the flat file connection.
Source Type
Select Single.
Source Object
Select TwitterStatus.txt.
6Click Next.
7On the Target page, configure the following fields:
Field
Description
Connection
Select the connection you created. For example: TwitterUpdate_REST
Target Object
Select update_json
8Click Next.
9On the Field Mapping page, map the TwitterStatus.txt source file to the URLPARAM_status field of the target object. If your POST call has a payload, define the payload in a flat file, and map the absolute path of the file to PAYLOAD_FileName in Field Mapping.
The following image shows the field mapping for URLPARAM_status:
field:
10Click Validate Mapping.
11Click Finish.
12To run the task, on the Explore page, navigate to the task, click Actions, and select Run.