Search code examples
pdfpostapache-nifi

NiFi- how to http post a PDF document


I wanted to use NiFi's posthttp/invokeHttp processor to post a PDF to an API.

But considering the following cURL request to replicate in NiFi:

curl -X POST "http://ipaddress:port/api/" -H "accept: application/json" -H 
        "Content-Type: multipart/form-data" -F "pdf_file=@sample.pdf;
        type=application/pdf"

Which property takes the -F information in nifi attributes?

Configuration for invokehttp right now: enter image description here enter image description here error: "400 Bad Request: The browser (or proxy) sent a request that this server could not understand."

Configration for posthttp right now: enter image description here error: server logs: readv() failed (104: Connection reset by peer) while reading upstream


Solution

  • In older version of nifi you will have to use your own script to build a multipart request and then use invoke to create post request. You can refer to this post for a ExecuteGroovyScript example. https://stackoverflow.com/a/57204862

    Since Nifi 1.12 you can directly use invokeHTTP by setting content-type https://stackoverflow.com/a/69284300