How to set up proxy

i am trying to convert RestAssured-Selenium Project to the Robot framework. I need help on setting up proxy for this method below. Thanks.

public static Response ticketCreate(TicketCreate payload) {
RestAssured.proxy(“some url”, 8080);
Object Routes;
return given()
.auth()
.preemptive()
.basic(readConfig.getAuthUsername(),readConfig.getAuthPassword())
.contentType(ContentType.JSON)
.accept(ContentType.JSON)
.body(payload)
.when()
.post(Routes.ticketCreate);
}

Hi Bayram,

You didn’t say which robot framework library you are using?

Since you are trying to script what looks like a REST API, I’ll take a guess at RequestsLibrary, the documenttaion on proxy settings can be found here Create Session

Dave.

Hi Dave,
Thanks for quick reply. Yes i am trying to use RequestLibrary. The documentation is not so clear to me .That s why i could not implement proxy setting the way i did in RestAPI. I searched but no luck finding an example so far.

List item

Hi Bayram,

So this

Becomes something like this:

	${proxies}= 	Create Dictionary 	http=some url:8080 	https=some url:8080
	Create Session 	yourapp 	http://your.app.server 	proxies=${proxies}
	POST On Session 	yourapp 	http://your.app.server/your/endpoint 	json=${jsonrequestbody}

The difference being that with your current code you need to all proxies, headers, cookies etc every time, with RequestsLibrary session, you only do it once for Create Session after that you can POST and GET on session as many times as you need

If you put the create session part in a suite setup you can use the same session for all your test cases and save yourself a lot of effort

Hopefully that clears things up,

Dave.

1 Like

Thanks your help Dave. After doing some small modification in your script , it worked well.

1 Like