Skip to Content
0
Mar 20 at 02:51 AM

Call WEB Services SAP IRPA

143 Views Last edit Mar 20 at 02:53 AM 2 rev

Hi, I am having trouble using the custom script to get data from an API, I tested it by POSTMAN and it worked...
I need to get the token to go to the next step of the process, but I can't, the API documentation tells me to use this request method, the token. To use this APIs you need to use a Bearer token, which can be obtained through an API, passing a user and password to an endpoint, in this model:

image.png
to do this I converted the above code to javascript returning this code below, but the POST request is returning blank, but if I do it with POSTMAN it works, can you help me?

I have downloaded the web services from the store to try to use it, but I can't tell which automation is the most appropriate for this process

async function fetchToken() {
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
role: 'enterprise',
username: '',
password: ''
})
};
try {
const response = await irpa_core.request.call('https://api.trizy.com.br/iam/auth', requestOptions);
return response;
} catch (error) {
return error;
}
}
let response = await fetchToken();
return response.headers;

Attachments

image.png (27.2 kB)