Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How in Intellij IDEA in new HTTP Client automate parse Response

I couldn't find how to automate parse responce and use in next GET request

###
POST http://localhost/coolsoftware/rest/authentication?login=username&password=1234
---- response will be
…
Set-Cookie: JSESSIONID=028EBF489BDF2D88A8A70935F4CA7C04; <-- I need this
…

###
GET http://localhost/coolsoftware/rest/bills/
Cookie: JSESSIONID=028EBF489BDF2D88A8A70935F4CA7C04; <-- to use here
like image 215
miroque Avatar asked Sep 06 '25 09:09

miroque


1 Answers

POST http://localhost/coolsoftware/rest/authentication?login=username&password=1234

> {% client.global.set("yourVariable", response.headers.valueOf('Set-Cookie')); %}

And then:

GET http://localhost/coolsoftware/rest/bills/
Cookie: {{yourVariable}}

If there are more than one Set-Cookie header, you should use valuesOf() instead (available in the latest EAP), and then iterate through the array assigning vars.

like image 87
Eugene Morozov Avatar answered Sep 08 '25 23:09

Eugene Morozov