cancel
Showing results for 
Search instead for 
Did you mean: 

Odata Service is showing error A security error is occurred

former_member671019
Discoverer
0 Kudos

Hi Team,

I am facing issue when trying to hit the GET request for oData service for production user service through Ajax call in iRPA. I used the template provided on Cloud factory store- production order completion.

below is sample ajax call which is getting generated through ajax call in template code and error.

{"ts":"13:09:07.173","ctx":"Action","action":"ctx.ajax.call","params[{"method":"GET","url":"http://hostname:port/sap/opu/odata/sap/API_PRODUCTION_ORDERS/A_ProductionOrder('XXXXXX')","contentType":"application/json","ignoreClientCertificate":true,"headers":{"Authorization":"Basic UlJBWVZFUk1BOlNvcHJhQDAx","x-csrf-token":"fetch","If-Match":"fetch"},"timeout":10000}],"parentId":94}

ts: '13:09:07.173'

ctx: 'Action' action: 'ctx.ajax.call' params: [0]: method: 'GET' url: 'http://hostname:port/sap/opu/odata/sap/API_PRODUCTION_ORDERS/A_ProductionOrder('XXXXX')' contentType: 'application/json' ignoreClientCertificate: true headers: Authorization: 'Basic UlJBWVZFUk1BOlNvcHJhQDAx' x-csrf-token: 'fetch' If-Match: 'fetch' timeout: 10000 parentId: 94

Error: status: 12175 statusText: 'A security error occurred' responseText: 'A security error occurred'

Note: There is no network firewall also behind that.

chirihan_chergui
Explorer
0 Kudos

Hi Ravi,

Have you tried calling the odata service from postman? Please make sure the GET call works in postman before using the service in IRPA.

Br

Chirihan

former_member671019
Discoverer

Hi chirihan.chergui ,

Service is working perfectly through postman/browser. problem on while making call through ajax script in iRPA.

S0016053750
Explorer
0 Kudos

Hi @rrayverma

Please help me out i have the same issue.

Accepted Solutions (1)

Accepted Solutions (1)

Jerome
Advisor
Advisor

Hello,

It is possible there is an issue with the ctx.ajax call method. If this is the case, please use the following workaround :

var command = 'curl <your options in the CURL command here>'
try {
ctx.exec(command, 30000, function(res){
// do what you need here, once you got the result of the WS call
});
}
catch (ex){
ctx.log('error : ' + ex.message);
}

You can find the manpage of CURL here.

Note : cURL is included in Windows 10 (build 17063 and above). If you run an older version of Windows, you'll need to download and install cURL by yourself.

krish469
Contributor

Thanks Jerome, From our clue and few days of stuggle I got to know how to work with Curl

https://blogs.sap.com/2020/07/14/working-with-sap-irpa-and-s-4-on-premise-system/?preview_id=1143429

chris_hanusch
Explorer
0 Kudos

Hello Jerome

long payloads don't seem to work.
The cmd prompt is being opened while executing via IRPA. It's not closing automatically and further steps can't be processed.

Answers (2)

Answers (2)

former_member314224
Discoverer

Hello,

I am facing a similar issue when I call the back end Api from RPA I am getting the error " A security error is occurred" with return code 12175. I appreciate any help here.

Using Ajax call to call the Api.

Srinivas-Rao
Contributor

Hi meghasyam.akula - If this is standard bot, then please change the cloud variable "IGNORE_CERTIFICATE_ERROR" to FALSE and see if it works. It worked for me. Kindly provide the update on what happens in your case so that we can look further.

Thanks & Regards

SR.

Jerome
Advisor
Advisor
0 Kudos

Hello,

Could you please post the piece of code you're using to call the service ?

Thanks,

J.

former_member671019
Discoverer
0 Kudos

Hi,

Below is code:

GLOBAL.step( {

invoke_get_api: function (ev, sc, st) {

var rootData = sc.data;

ctx.workflow('Production Order Completion', '8d1bc27e-444e-4bbe-aaf1-d424376b8e87');

// invoke_get_api

var url = sc.localData.systemUrl + sc.localData.Resources['settings']['api_get'] + sc.localData.listOfPos[sc.localData.Startloop].PO + "')";

var opts = {

"username" : sc.localData.credentials.Username,

"password": sc.localData.credentials.Password

}

function success(res, status, xhr) {

sc.localData.csrf = xhr.headers["x-csrf-token"];

sc.localData.etag = xhr.headers['ETag'];

sc.localData.cookies = xhr.headers["Set-Cookie"].split('; ')[0] + "; ";

sc.endStep(); // invoke_post_api

return ;

}

function error(res, status, xhr) {

sc.endStep(); // invoke_post_api

return ;

}

API.GET(url, opts, success, error);

}

and here is GET method:

var API = {

GET: function (url, opts, success, error) {

ctx.ajax.call( {

method: e.ajax.method.get, // it is implicit

url: url,

contentType: e.ajax.content.json, // input data are added in URL: '...?...&...'

ignoreClientCertificate:true,

headers: {

'Authorization': 'Basic ' + ctx.base64.encode(opts.username + ':' + opts.password),

'x-csrf-token':'fetch',

'If-Match':'fetch'

},

success: function (res, status, xhr) {

success(res, status, xhr);

},

error: function (res, status, xhr) {

error(res, status, xhr);

},

timeout:10000

});

},

former_member671019
Discoverer
0 Kudos

@jeromegrondin

Could you please share any update if it is resolved.

Jerome
Advisor
Advisor
0 Kudos

Hi,

Did you try to use CURL as mentionned in another answer ?

J.