1

I have a 3rd party REST, which I am successfully able to call like this using CURL (shell). This API return JSON. I tried calling same API, by changing content type to application/x-www-form-urlencoded but it doesn't work. I think I am forced to use content-type: multipart/form-data

curl --request POST --url https://************************* --header 'Authorization: Bearer ********'  --header 'content-type: multipart/form-data; ' --form cluster_id=0717-035521-puny598 --form start_time=1534357800000 --form end_time=1534444199999 --form order=ASC --form limit=500

Now I want to call same API using InvokeHTTP processor (NiFi). So I configured it as follows. But I am not able to do a successful call. (it is not a proxy issue).

enter image description here

enter image description here

Following is how I am creating POST body (by FF)

enter image description here

I have tried replacing "enter" by \r\n etc, or changing body as name1=val1&name2=val2&.... etc. nothing worked.

This is the response I am getting.

[enter image description here]

I am able to run CURL (shell, from same server where Nifi is running). Also I am able to access url via postman.

[enter image description here]

Rakesh Prasad
  • 602
  • 1
  • 13
  • 32
  • fixed image display – taras Aug 20 '18 at 12:18
  • What does "nothing worked" mean? Are there errors thrown? Is the HTTP request made? Do you get a response? Can you point the processor at a local HTTP server to observe the request and compare it with the `curl` command you are issuing? – Andy Aug 20 '18 at 18:23
  • If the remote endpoint is HTTPS, you'll need to provide a `StandardSSLContextService` implementation in the *SSL Context Service* property of the `InvokeHTTP` processor. You should configure the truststore properties with the JVM `cacerts` file, and the default password is `changeit`. – Andy Aug 20 '18 at 18:24
  • @Andy : yes, I am getting response. Its 500. Server is saying request body is malformed. also CURL and POSTMAN works. Also I doubt it is to do with https, as I am able to call other URLs/APIs to same provider, and all thr URLs are https. My doubt is how Nifi is sending form multipart. – Rakesh Prasad Aug 21 '18 at 03:07

2 Answers2

0

finally, it worked. flow is somewhat like this.

GenerateFlowFile->UpdateAttribute->AttributesToJSON->InvokeHTTP

Only change, I made to InvokeHTTP. reverted content-type back to ${mime.type}.

Rakesh Prasad
  • 602
  • 1
  • 13
  • 32
0

I was struggling with this for a few hours. I've got a backend API that has

ResponseEntity<ByteArrayResource> post (@RequestPart("file") MultipartFile file) and a NiFi processor that sends XLSX data to this. I was getting the same issue... The key for me were the bottom two properties:

FlowFile Form Data Name -> file (this is the name of the variable in the API call)

Set Flowfile Form Data File Name -> true