Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

How to add Content-Type=application/json to InvokeHTTP

avatar

I am using the InvokeHTTP processor. I need to post a json to a REST URL. I get the json via a GetFile processor, then manipulate it and finally route it to the InvokeHTTP processor. Well I get an error (412 HTTP code) because I am not able to specify teh content-type.

How can I do it?

Dynamic properties?

Help please,

Massimiliano

1 ACCEPTED SOLUTION

avatar

I have solved by upgrading to version 0.5.0.

View solution in original post

5 REPLIES 5

avatar
Master Guru

The documentation for InvokeHttp says that Dynamic properties are sent as headers:

NameValueDescription
Header NameAttribute Expression LanguageSend request header with a key matching the Dynamic Property Key and a value created by evaluating the Attribute Expression Language set in the value of the Dynamic Property. Supports Expression Language: true

So you should be able to add a property Content-Type with a value of application/json.

https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.InvokeHTTP/ind...

avatar
Rising Star

InvokeHTTP makes use of the "mime.type" attribute. Depending on the version you are using, this may or may not be exposed as a property "Content-Type" which defaults to the expression language "${mime.type}"

avatar

It is like this from version 0.5.0.

avatar

First of all, thank you for both answers.

I am working with version 0.4.

I have added a property "Content-Type" with a value of "application/json" and it is not worling.............should i keep the quotes?

Regarding the secons answer...............do you mean I have to amend the mime.type attribute to "application/json"? If so, how?

Thank you,

Regards,

Massimiliano

avatar

I have solved by upgrading to version 0.5.0.