Setting a Cookie

(George Reese) #1

How do you set a cookie for an httpGet()?

(Staugaard) #2

I also would love to find out about this. Setting a “Cookie” header does not work.

(George Reese) #3

I can’t even figure out how to set a request header. How do you do that?

(Luke) #4

First you’d need to capture the value from the “Set-Cookie” header included in the response from an authentication request to the external server in question. You could store that in state, maybe using something like this:

state.cookie = response?.headers?.'Set-Cookie'?.split(";")?.getAt(0)

Then in any subsequent request to this external server, you could use that cookie as follows:

httpGet(uri: '', headers: ['Cookie': state.cookie]) { response ->
  log.debug "Here is the response: ${}"

(George Reese) #5

Just as a follow up, I’m all good on cookies.