How to call a web service using token in UI path

I want to call a web service using token in UI path.

Hey @ShirinParkar

Go through below existing thread and you will get many linked posts too all are having the information which you are looking for :slight_smile:

Regards…!!
AKsh

1 Like

I am trying to call ‘http://api.openweathermap.org/data/2.5/weather’ service using HTTP request activity but it is giving Proxy Authentication Required error.

Hi @ShirinParkar

Could you provide some screenshots?

Have you tested your HTTP Request activity with a simple query, such as even this thread as url:
https://forum.uipath.com/t/how-to-call-a-web-service-using-token-in-ui-path/83768.json

Hello,
I’m facing the same issue, i need to automate the token generation with uipath and pass it in argument in http reques.
i have a private and public key, header and payload, but i couldn’t decode and hash to create the token using uipath.
Could you please help ?

Hi @hzarriq

Could you please provide more information? Showcasing how you are currently achieving the same flow in another tool such as Postman would help here.

i’m using jwt.io, i pass header, payload, private key and public key ( which is authorised from the web service). i change the expiration date in the payload and the token is generated. this algorithm works this way : $jwt = $encodedHeader + ‘.’ + $encodedPayload +"." [convert]::ToBase64String($privateKey.SignData($toSign,“SHA256”)).
$toSign = $encodedHeader + ‘.’ + $encodedPayload
I also fount a java program that do the same, but for some security reasons i don’t have to invoke Java code.

java program
public String createToken(final String userId, final String username, final Set roles, final String realm) {
final Claims claims = Jwts.claims();
final Date now = new Date();
final Date validity = new Date(now.getTime() + expiration);

    claims.setSubject(username);
    claims.put(USER_ID_KEY, userId);
    claims.put(USER_ROLES_KEY, roles);
    claims.put(REALM_KEY, realm != null? realm : DEFAULT_REALM);

    return Jwts.builder()
        .setClaims(claims)
        .setIssuedAt(now)
        .setExpiration(validity)
        .setHeaderParam("typ", "JWT")
        .signWith(SignatureAlgorithm.RS256, this.privateKey)
        .compact();
}

I think the first step would be to try and do the same action with Postman. Afterwards, it should be relatively straightforward to reproduce the same by using one (or several) HTTP Requests.

1 Like

Hi @Shirin i have this example that I use with students using OpenWeather API

OpenWeatherAPI.zip (3.6 KB)

Hope it helps!

1 Like