If you prefer watching videos, you can watch the first two videos available in the SAP Ariba for Developers YouTube playlist ? https://www.youtube.com/playlist?list=PL6RpkC85SLQDXSLHrSPtu8wztzDs8kYPX.
To find out how to create a trial account: https://developers.sap.com/tutorials/hcp-create-trial-account.html
Fig. 1 - Integration flow
API & Services > Credentials
. Create a credential for OAuth Client ID and select Web application as the application type. Make sure to add https://auth.cloudelements.io/oauth
as an Authorised redirect URI. Once the client is created, copy the Client ID and Client secret as we will need them to configure an instance of BigQuery in Open Connectors.Fig. 2 - Google Cloud Platform OAuth credentials
Fig. 3 - Integration Suite UI
Fig. 4 - BigQuery connector configuration
User QNBF4V=, Organization a0f234e, Element d3jbWv5/xxx/yyyyyyy/zzzzxqrk=
. We will use this value to configure the Open Connector credentials in the next step.Fig. 5 - Open Connector API docs
Name | Type | Fields |
---|---|---|
Ariba_AnalyticalReporting | OAuth2 Client credentials | Enter the Token service URL, Client ID and Client Secret |
OC_BigQuery | User credentials (Open Connectors) | Enter the User, Organization, and Element details from Open Connectors |
![]() | ![]() |
Fig. 6 - Security material
To understand how pagination works in the SAP Ariba APIs, check out the explanation in Exercise 08 of the Cloud APIs virtual event - Data pagination with SAP Ariba APIs.
Fig. 7 - Externalized parameters
⚠️ When developing the integration flow I faced an issue when posting the payload to BigQuery (Open Connector). Given that I will be creating multiple records in a single request, I need to post the file as a . When posting the file, I was always getting the error below. I followed mattisebastian advice to replace the\n
with\r\n
, but still was unable to successfully post the message using the Open Connectors adapter. Hence why I end up using the HTTP adapter and constructing/cleaning the payload (Set Content-Type and form-data elements content modifier) in the integration flow.
com.sap.it.rt.adapter.openconnectors.exceptions.OpenConnectorsException: Error occured in Http Request :
com.sap.it.rt.adapter.openconnectors.exceptions.OpenConnectorsException: Invalid Multipart Formdata Payload, cause:
com.sap.it.rt.adapter.openconnectors.exceptions.OpenConnectorsException: Invalid Multipart Formdata Payload
Fig. 8 - Looping process conditions
importClass(com.sap.gateway.ip.core.customdev.util.Message);
importClass(java.util.HashMap);
function processData(message) {
// Set the value for filters query parameter
message.setHeader("dateFilter", '{"createdDateFrom":"2019-07-01T00:00:00Z","createdDateTo":"2020-06-05T00:00:00Z"}');
return message;
}
{{Ariba_APIKey}}
external parameter.PageToken
value in the API response and handles its value. This will be used to indicate if the looping process should continue or finish. It also prepares the file that the Open Connector BigQuery instances expects. The contents of the file expects a JSON structure per line and every line will be the equivalent of a record in BigQuery.importClass(com.sap.gateway.ip.core.customdev.util.Message);
importClass(java.util.HashMap);
function processData(message) {
var messageLog = messageLogFactory.getMessageLog(message)
//Parsing body to JSON
var body = JSON.parse(message.getBody(new java.lang.String().getClass()));
/* ===========
Handle PageToken
=============*/
// Retrieving PageToken from payload if one exists
if("PageToken" in body) {
messageLog.setStringProperty("PageToken", body['PageToken']);
message.setHeader("pageToken", body["PageToken"]);
} else {
messageLog.setStringProperty("PageToken", "NONE!");
message.setHeader("pageToken", "STOP");
}
/* ===========
Create payload
=============*/
var fileContents = "";
var i = 0;
var arr = body['Records'];
for(var x = 0; x < arr.length; x++) {
var record = arr[x];
messageLog.setStringProperty("record", record);
i += 1;
// Create JSON line document
fileContents += '{"Status": "' + record['Status'] + '","InternalId": "' + record['InternalId'] + '","Title": "' + record['Title'] + '"}\n';
}
messageLog.setStringProperty("TotalRecordsProcessed", i);
message.setBody(fileContents);
return message;
}
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="payload.json"
Content-Type: application/json
${body}
------WebKitFormBoundary7MA4YWxkTrZu0gW--
import com.sap.gateway.ip.core.customdev.util.Message;
import com.sap.it.api.ITApiFactory;
import com.sap.it.api.securestore.SecureStoreService;
import com.sap.it.api.securestore.UserCredential;
import com.sap.it.api.securestore.exception.SecureStoreException;
def Message processData(Message message) {
def messageLog = messageLogFactory.getMessageLog(message);
/* ============
Set Authorization header
=============== */
def service = ITApiFactory.getApi(SecureStoreService.class, null);
if( service != null)
{
// Retrieve credential name from property
def credentialName = message.getProperties()["OC_Credential"];
//Get UserCredential containing user credential details
def credential = service.getUserCredential(credentialName);
message.setHeader("Authorization", new String(credential.getPassword()));
}
/* ============
Modify payload
=============== */
def bodyStr = message.getBody(java.lang.String) as String;
messageLog.setStringProperty("beforeBody", bodyStr);
// Replacing problematic characters
body = bodyStr.replaceAll("\n", "\r\n");
messageLog.setStringProperty("afterBody", body);
message.setBody(body);
return message;
}
{{OC_bulk_table_URL}}
external parameter.
Fig. 9 - BigQuery HTTP adapter configuration
Fig. 10 - BigQuery table data
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
3 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |