Support Questions

Find answers, ask questions, and share your expertise

Nifi 2.0.0 \ Invoke HTTP process (Get) with body

avatar
Explorer

Dears ,

Kindly note that I am trying to send InvokeHttp request as Get with the following body=   

{
    "Domain": [
        ["write_date",">=","2024-07-01 04:00:00.000"],
        ["write_date","<=","2024-07-12 04:00:00.000"]
    ]
}
 
 
I have done some investigations and found no solution for my problem
 

   

11 REPLIES 11

avatar
Super Guru

Hi,

Can you elaborate more on the issue. For example are you getting an error? what is the status code of the response?I assume you are using InvokeHttp processor,   Can you paste screenshot of the  configuration you have ? What kind of API is it and are you sure this a GET API vs Others ? Have you tried to do the GET from pastman or curl ? was it successful?

It seems using body with Get API is not good idea after all per below links , so if its something developed internally you probably should re consider.

https://www.linkedin.com/pulse/using-body-http-get-method-still-bad-idea-danny-logsdon

https://www.baeldung.com/cs/http-get-with-body

 

 

avatar
Explorer

Dear,

Kindly note that I am using a GET request inside the InvokeHTTP processor. As mentioned above, in order to retrieve the desired data, I need to send a body with the GET request. However, it's working inside Postman.

Ali_12012_0-1721121571007.jpeg

When it comes to nifi apache 2.0.0 when i run the invokehttp processor(Get) queues remains empty with no errors since no body is sent with request.

Ali_12012_1-1721121908458.png

Ali_12012_2-1721122072571.png

while it works for other Get requests that need no body.

Is there a solution for this case with additional processes to be added  ? or some configurations?

please advice?

 

avatar
Explorer

Dear,

Any updates?

avatar
Master Mentor

@Ali_12012 

The documentation for InvokeHTTP states that only POST, PUT and PATCH http methods will sent with a body.  The processor does not support sending a body with GET http method.  Only supports headers.

You may need to build a custom processor for your use case or perhaps use one of the scripting processors to accomplish your use case.


Thank you,
Matt


avatar
Explorer

Dear Mattwho,

Please find the above reply from my side.

How is it possible to be fixed by some script process while invokehttp get request can not be sent with body?

avatar
Master Mentor

@Ali_12012 

The InvokeHTTP processor utilizes the OkHTTP client library.  This library does not support a body in a get request:
https://github.com/square/okhttp/issues/3154

 I am not familiar myself with what other client libraries exist that support this method, but guessing there must be some out there since postman handles this for you.

The script process allows you to create a custom code that can use whatever client libraries you want.  You could also build you own custom processor that utilizes some other client that may be able to identify that supports get with a body.  

Sorry I can't be of more help here.  As @SAMSAL shared, there are reason why this is not supported or standard convention. Postman does not adhere to those standards and lets you do what you want.

Please help our community thrive. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.

Thank you,
Matt

avatar
Community Manager

@Ali_12012 Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future.  Thanks.


Regards,

Diana Torres,
Community Moderator


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:

avatar
Explorer

Dear Diana,

No, the above reply did not help me however I found a solution to my problem through internet.

Best Regards,

 Ali.D

 

avatar
New Contributor

Dear @Ali_12012 , 
I encountered the same problem as you, please tell me how you solved it?
Help me please with a solution.🙏