2024 Oct 25 10:43 AM - edited 2024 Oct 28 8:53 AM
Hi,
I would like to know if you could give me a quick hand regarding a pretty straight-forward API call that I have been trying to make in an automation in iRPA for a couple of days now. The problematic API is API 1 (API 2 is working like a charm in iRPA), see details as below.
The authentication process consists in calling two APIs consecutively:
API 1: method GET, no parameter, returns a token named XSRF-TOKEN within the response cookie that I need to retrieve in order to use it in:
API 1 is working in Postman but somehow I can't make it function in iRPA.
These are some of my attempts (code as part of a custom script), some of them might be awkward (sorry):
a.
return {
method: 'GET',
url:'https://sandbox.entreprises.xxxx.gouv.fr/api/init',
responseType: 'json',
resolveBodyOnly: false
headers:{
}
};
=> Response code 500 (Internal Servor Error)
b. (N.B.: that one was recommended by SAP Web services Best Practices, see screenshot below)
return {
method: 'GET',
url: 'https://sandbox.entreprises.xxxx.gouv.fr/api/init' ,
responseType:'json',
resolveBodyOnly: false
};
=> Response code 500 (Internal Servor Error)
c. (this is the one I use for API 2, which is working, thought I would try the same for API 1)
const options = {
resolveBodyOnly : false,
responseType: 'json',
url: 'https://sandbox.entreprises.xxxx.gouv.fr/api/init',
method: 'GET',
headers: {
'Accept' : 'application/json',
'Content-Type': 'application/json',
}
};
const response = await irpa_core.request.call(options);
return response.headers;
=> Response code 500 (Internal Servor Error)
d.
async function fetchToken () {
const options = {
resolveBodyOnly : true,
responseType: 'json',
url: 'https://sandbox.entreprises.xxxx.gouv.fr/api/init',
method: 'GET',
headers: {
'Accept' : 'application/json',
'Content-Type': 'application/json',
'XSRF-TOKEN': 'fetch'
}
};
const response = await irpa_core.request.call(options);
return response;
=> Response code 500 (Internal Servor Error)
It is not the first time I handle API calls in SAP iRPA, and it always succeeded even with more complex ones. The irony of this being that I managed to make the API 2 work in iRPA.
Automation in itself is also quite simple: custom script (with no input) => call web service => create variable. See here:
Note that I already read detailed blogs, tutorials and videos (for which I am very grateful) before contacting you. I’m kind of disarmed in front of something that should supposedly be simple to run…
Would you have any clue how to make this work please?
Thanks beforehand for your time and I’m looking forward to reading you.
Kind regards,
LM.
Request clarification before answering.
Hello Ludovic,
Thanks for confirmation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
62 | |
8 | |
8 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.