How to set basicAuthorization in a request object?


I’m wondering how the basicAuhtorizzation works with the new RestRequestObjectBuilder() ?

I’m trying something like this :

	RequestObject ro = new RestRequestObjectBuilder()

with :

	public BasicRequestAuthorization getRequestAuthorization() {
		return new BasicRequestAuthorization().setAuthorizationInfo([username:passwrod])

But it doesn’t seems to work in the end ? :thinking:

As mentioned here Web Services Builder in Katalon Studio | Katalon Docs, this authorization should used by version > 8.4.0, please double check about the version. In the meanwhile, let me read about it more. I just found this document BasicRequestAuthorization if relevant.

Thankls for your answer, Elly_Tran :slight_smile: I’m using the last version so 8.5.0. I’m not sure if I’m using correctly the setAutoriationInfo. Is it a map with username as key andf password as value ? Or do we need something else ?

Are those valid variables?
The method expect a Map<String, String> signature.
So if you intend to pass them as they are, perhaps you should use ["username":"passwrod"]

(and take care about the typo)

Lol, I just realized my variable name for password was incorrect when reading your post :sweat_smile:

I’ll change that. And yes, they are String variables :slight_smile:

Still not working :

<head><title>401 Authorization Required</title></head>
<center><h1>401 Authorization Required</h1></center>

For :

		RequestObject ro = new RestRequestObjectBuilder()
		return ro

Well … I have no other idea other than inspect your BasicRequestAuthorization object and check if everything needed is in place.
E.g the RequestAuthorization class have also a setAuthorizationType method.
I would expect that BasicRequestAuthorization override it and set it to Basic by default … but something may be wrong somewhere.
the API doc is a bit confusing

1 Like

I have already tired it but it change nothing. Honestly for me, the BasicRequestAuthorization as it is in the 8.5.0 does not work.

Is there another way to use basic auth in katalon ?

@luc.namur you are not following my advice, therefore without aditional input the comunity cannot help.

we are not here to debug katalon products.

if you are a licensed user, you can open a ticket with katalon bussines support.

otherwise wait until a certain relevant developer will look into this, when the moon phase is appropiate and the planets alignment is beneficial.