Created 04-03-2018 09:28 AM
Hi,
I want to post data to external service using curl command from Pig. Is it possible to run curl command from Pig?
Created 04-03-2018 09:45 AM
Yes. You can run curl command in pig. You can run shell commands in pig using "sh {command}"
Here is the sample.
[root@test-instance-1 ~]$ pig grunt> sh curl -k -u admin:admin -H "X-Requested-By:ambari" http://localhost:8080/api/v1/clusters % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed { "href" : "http://localhost:8080/api/v1/clusters", "items" : [ 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 { 100 236 100 236 0 0 3808 0 --:--:-- --:--:-- --:--:-- 3868 "href" : "http://localhost:8080/api/v1/clusters/cl1", "Clusters" : { "cluster_name" : "cl1", "version" : "HDP-2.6" } } ] }
Additional reference : https://pig.apache.org/docs/r0.11.1/cmds.html#sh
Please accept the answer if this helps.
.
-Aditya
Created 04-05-2018 09:22 AM
I want to post pig relation output to external service using curl. How to pass pig relation values in a below curl command :
curl -X POST http://xxx.xx.xxx.xx/services//api/data -H "accept: application/json" -H "authorization: authorization-token value" -H "cache-control: no-cache" -H "content-type: multipart/form-data;boundary=----xxxxxxxxxxxxxxxxx" -H "postman-token:postman-token value" -F "title=the value which i want to fetch from pig relation " -F "description=descirption"
i want to fetch value for title from pig relation.