Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

Solved Go to solution

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

New Contributor

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

Accepted Solutions
Highlighted

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

New Contributor

I have solved by upgrading to version 0.5.0.

5 REPLIES 5

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

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...

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

Contributor

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}"

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

New Contributor

It is like this from version 0.5.0.

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

New Contributor

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

Highlighted

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

New Contributor

I have solved by upgrading to version 0.5.0.