Skip to main content
Amn
Silver ⭐️
July 1, 2021
Solved

Nifi InvokeHTTP failure response

Hi,

I am using invokeHTTP processor for calling REST API when that REST api gives error like 422 or other it is also sending reason in response body.

 

I want to retrieve that message and send it on mail but on this kind of error flow go into retry or no retry which gives me original flow file only.

 

Can anyone pls help me to retrieve response body in this case instead of original flow file.

 

Thanks in Advanced.

adhishankarit
Gold ⭐️
July 1, 2021

Hi ,

 

The InvokeHTTP processor provides couple of the write attributes with value for example invokehttp.status.code
401
invokehttp.status.message
Unauthorized

 

when you have this attributes  in Failure or No Retry relationship ,you can use Replace text processor as below to overwrite the original flow into new flow file so that you send that in email .

HTTPErrorAndMessage.PNG

 

ReplaceText processor properties 

ReplaceText#.PNG

 

If you are looking for lot more message of the response body , please check whether you can configure in any attribute in InvokeHTTP processor so that you can use it ReplaceText processor to overwrite the original flow file  

2 replies

adhishankarit
Gold ⭐️
July 1, 2021

Hi ,

 

The InvokeHTTP processor provides couple of the write attributes with value for example invokehttp.status.code
401
invokehttp.status.message
Unauthorized

 

when you have this attributes  in Failure or No Retry relationship ,you can use Replace text processor as below to overwrite the original flow into new flow file so that you send that in email .

HTTPErrorAndMessage.PNG

 

ReplaceText processor properties 

ReplaceText#.PNG

 

If you are looking for lot more message of the response body , please check whether you can configure in any attribute in InvokeHTTP processor so that you can use it ReplaceText processor to overwrite the original flow file  

Translate
Amn
AmnAuthor
Silver ⭐️
July 9, 2021

Hi adhisankrit,

 

thanks a lot for help, i am new to NIFI. 

this solution worked.

Basically their are write attributes present in processor where status and response etc stuff are present which can be accessed.

Translate