cancel
Showing results for 
Search instead for 
Did you mean: 

IRPA 2.0 Call Webservice

Muthu_Prabakara
Explorer
0 Kudos
1,629

Hello,

I'm working on IRPA 2.0 based on cloud SDK. I have to call the standard S4 HANA API in my IRPA bot to get the data and post it to standard standard transaction.

I'm referring the https://help.sap.com/doc/d69213c343964f97af7829a37f4c6d4d/Cloud/en-US/modules/request.html standard documentation to call webservice however it doesn't provide any information on how to pass authorization to the API URL via header.

Please suggest how we can authorize the API while using irpa_core.request.call.

Thanks,

Muthu

Accepted Solutions (1)

Accepted Solutions (1)

TJe
Product and Topic Expert
Product and Topic Expert

Here an example from SAP BusinessObjects application, may still be useful to guide you in the right direction:

Logon request (code snippet) to get a session token

const body = JSON.parse(parameter.body);
const options = {           
    resolveBodyOnly : true, 
    responseType: 'json', 
    url: JSON.parse(parameter).baseUrl + 'logon/long',
    method: 'POST',
    headers: {
      'Accept' : 'application/json',
      'Content-Type': 'application/json'
    },
    body :  JSON.stringify({
        'password': body.password,
        'clientType': '',
        'auth': 'secEnterprise',
        'userName': body.userName
    })
};
const response = await irpa_core.request.call(options);
//irpa_core.core.log(response);
parameter.logonToken = response.logonToken;

Logoff reqeust (code snippet) using the session token

const body = JSON.parse(parameter.body);
const options = {           
    resolveBodyOnly : true, 
    responseType: 'json', 
    url: JSON.parse(parameter).baseUrl + 'logoff',
    method: 'POST',
    headers: {
      'Accept' : 'application/json',
      'Content-Type': 'application/json',
      'X-SAP-LogonToken' : parameter.logonToken
    }
};
const response = await irpa_core.request.call(options);
//irpa_core.core.log(response);
Muthu_Prabakara
Explorer

Thanks!! it worked.

Answers (0)