Tuesday 12 December 2017

SAP API call (api.sap.com) from SAP HCI (SCPI):


I had tried out multiple sites/blog for the reference to develop this integration between SAP HCI and SAP provided API. But No Luck!!!
Then started to develop this iflow to translate the given text from one language to other language. There is pre packed API available in the SAP API portal. Just I am trying to access the API from HCI as translated output.
Here you can either pass the data in the file or content modifier. I will show you in the content modifier for input data passing to API.

IFLOW in SAP HCI:



Whenever the iflow is deployed Start Event triggered and content from the content modifier sends to SAP API for the translation.
Content Modifier:
In Header, the parameters need to pass as below:

Will let you know where to take this API key and the Content Type need to be provided as  application/json, else you will get an error.

  • If you are giving Content-Type as application/xml , will get error code : 415
  • If no input is given to this API and triggered the iflow, will get the error code: 411
  • If no API key is given to this API and triggered the iflow, will get the error code: 401

Content Modifier: Body input text:
Can specify the source and target language as shown below for translation.
{
  "sourceLanguage": "en",
  "targetLanguages": [
    "de"
  ],
  "units": [
    {
      "value": "I would like to analyze my sales data."
    }
  ]
}
HTTP Channel with Request Reply:

As the API call is synchronous, so used Request Reply step for send and get a response immediately.

HTTP Channel Configuration:
This HTTP channel parameter required the API Request Address where it took from SAP API portal.
Method: POST
Authentication: None


Receiver can be anything you required. This ends the configuration in SAP HCI. Next can look in the SAP API Sandbox portal which is free for usage.

URL for accessing the Portal:  https://api.sap.com


There are several API developed and placed in the Portal as below: Will look into SAP Leandro Machine Learning-Functional Services for Translation.



Click on Artifacts – Click on Translation API

Select Expand Operations as highlighted below:

We have a provision to test the API in the portal itself as shown.
Click on Click to set the parameter value this gives the input  in the body column then you can click on Try it button. Response of the API appears below.

Below mentioned Request URL will be given as the HCI HTTP channel address:
Response also appeared below.


Right corner of the screen we have the API Key, this is used in the Content modifier as shown below in screenshot:


Same input is gives as shown above and received the response in HCI output:



Hence this end. Happy Learning!!!






1 comment: