zamentali
zamentali

Reputation: 330

Apache Nifi : How to pass post params and capture response from post API - traditional non rest, non json API

I'm trying to pull data from a post API that expects authentication and request parameters as part of the request body. I guess, what they do is access the data from the post variables.

What I have seen so far in documentation is how to send POST via JSON or headers. In my case, no headers just the post body parameters.

call to this api via curl --data option works just fine.

curl --data "username=xyz&password=xyz&function=xyz" http://example.com/api.php

How can I replicate above call in nifi?

I have tried multiple methods without success. Latest has been Generate flow file, update attributes (where i fill in the parameters), invoke http then putfile.

But I'm getting errors - the api is not abe to authenticate my request.

Thanksenter image description here

Upvotes: 1

Views: 6469

Answers (1)

daggett
daggett

Reputation: 28564

If you need to send the following data in body, then put it into content of your flowfile.

username=xyz&password=xyz&function=xyz

The easiest way to put it into the Custom Text property of the GenerateFlowFile processor.

Usually for this kind of body you have to provide content type header:

content-type: application/x-www-form-urlencoded

If you don't need any additional headers then you don't have to define any additional attributes of the flow file.

Upvotes: 2

Related Questions