Created 03-02-2016 08:23 AM
Hi,
I made a Nifi template with 3 processor : GetFile -->InvokeHttp-->PutHdfs.
InvokeHttp makes a POST request to the facebook graph api and receives a JSON which is wrote in hdfs by PutHdfs. The issue i have is that the request i make doesn't seem to depend on the file read by GetFile. I read the Nifi documentation on InvokeHttp but i didn't find/understand the answer, hence my question.
Thank you in advance.
Created 03-02-2016 10:00 PM
I was able to generate and send JSON to InvokeHttp POST using a test endpoint (http://httpbin.org/post), it read the incoming flow file contents (the JSON) and correctly responded based on the input file.
Does the InvokeHttp response make sense for what you intend to send via POST? If not, you may need to (if you haven't already) set the "mime.type" attribute to "application/json" before sending the flow file to InvokeHttp. This can be done with the UpdateAttribute processor (see my example template below).
If GetFile still doesn't seem to work, perhaps try ListFile followed by FetchFile. Having said that, I wouldn't think this would make a difference, I suspect there's something else in the flowfile content and/or attributes (or a lack thereof) that causes InvokeHttp to not respond as intended.
My template is available as a Gist (here).
Created 03-02-2016 10:00 PM
I was able to generate and send JSON to InvokeHttp POST using a test endpoint (http://httpbin.org/post), it read the incoming flow file contents (the JSON) and correctly responded based on the input file.
Does the InvokeHttp response make sense for what you intend to send via POST? If not, you may need to (if you haven't already) set the "mime.type" attribute to "application/json" before sending the flow file to InvokeHttp. This can be done with the UpdateAttribute processor (see my example template below).
If GetFile still doesn't seem to work, perhaps try ListFile followed by FetchFile. Having said that, I wouldn't think this would make a difference, I suspect there's something else in the flowfile content and/or attributes (or a lack thereof) that causes InvokeHttp to not respond as intended.
My template is available as a Gist (here).
Created 03-02-2016 10:36 PM
Thank you very much. I'll have a look at it tomorrow.
Created 03-03-2016 01:19 PM
Adding the update processor with the mime.type attribute set to "application/json" solved the problem. *insert thank you gif*
Created 03-03-2016 12:33 PM
I juste tested the InvokeHTTP to post messages in my Facebook profile and it does work. I tried with the following dataflow:
To post a hello message on my feed I created a text file with the following content : "message=Hello+from+NiFi&access_token=PUT-YOUR-ACCESS-TOKEN-HERE" in /tmp/input and the message was posted in my profile.
ps: use the data provenence tool for debugging. It is very useful.
Created 03-03-2016 01:31 PM
Thank you for your answer, the always output response property will certainly be usefull. I'm not trying to post anything on facebook. I want to make multiple requests to the graph API. According to the facebook documentation, i need to post a json with a batch of my requests (or something close). If you have any infos about that or an example, please post it under this question : https://community.hortonworks.com/questions/20104/trying-to-make-multiple-request-to-facebook-graph....
Created 03-03-2016 02:21 PM
The approach that I gave is general and can be applied to issue any post request to Facebook. Posting something to a feed was just an example.
To achieve what you are trying to do, just put your batch request JSON together with access_token in the input file and you will get the results JSON. Here is an example that's working for me:
batch=[{"method":"GET", "relative_url":"me"},{"method":"GET", "relative_url":"me/friends"}]&access_token=your-access-token
In the InvokeHTTP use the following URL: https://graph.facebook.com/