Support Questions

Find answers, ask questions, and share your expertise

Can NiFi InvokeHTTP handle Cookies?

avatar
New Contributor

I use an InvokeHTTP processor to POST login details to a website

This returns a Set-Cookie attribute

Then I use another InvokeHTTP to request some JSON from a REST endpoint. I have created a Cookie attribute as ${Set-Cookie:substringBefore(';')} and added Cookie to "Attributes to Send" to use it as an HTTP header.

The problem is that this 2nd InvokeHTTP fails authentication and returns a 401.

If I manually log in and copy the Cookie value to the 2nd InvokeHTTP's parameters, the call works. In either case the Data provenance shows a valid Cookie value but the call always returns a 401 when the value comes from the dynamic value, so I am a bit lost.

3 REPLIES 3

avatar
New Contributor

Hello,

 

I encounter a completely similar issue ...

avatar
Super Guru

Hi @n_tulett ,

 

The Set-Cookie attribute returned by the first processor must be added as a Cookie header for the next InvokeHttp processor. You can do this by adding the following dynamic property to the second InvokeHttp processor:

araujo_0-1644800179712.png

Regards,

André

--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.

avatar
Super Guru

@hanscardoen This should solve you issue as well.

--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.