Support Questions
Find answers, ask questions, and share your expertise

I am using HDP 2.4 Sandbox. I want to Create Policy in Apache Ranger through REST API call from web page. Request if I can get the API call syntax. Can I make the API call from HTML form POST method? Thanks Hari

New Contributor
 
4 REPLIES 4

Re: I am using HDP 2.4 Sandbox. I want to Create Policy in Apache Ranger through REST API call from web page. Request if I can get the API call syntax. Can I make the API call from HTML form POST method? Thanks Hari

rest url : http://<ranger_admin_host>:6080/service/plugins/policies

Post request Data:

{"policyType":"0","name":"<pol_name>","isEnabled":true,"description":"","isAuditEnabled":true,"resources":{"path":{"values":["*"],"isRecursive":true}},"policyItems":[{"users":["<user>"],"accesses":[{"type":"<permission_type>","isAllowed":true},{"type":"write","isAllowed":true},{"type":"execute","isAllowed":true}]}],"denyPolicyItems":[],"allowExceptions":[],"denyExceptions":[],"service":"<repo_name>"}

you can make curl call or through postman

Re: I am using HDP 2.4 Sandbox. I want to Create Policy in Apache Ranger through REST API call from web page. Request if I can get the API call syntax. Can I make the API call from HTML form POST method? Thanks Hari

Expert Contributor

@Hari Shankar Sudhakaran

Please refer this documentation on RANGER REST APIs.

https://cwiki.apache.org/confluence/display/RANGER/REST+APIs+for+Service+Definition%2C+Service+and+P...

Example rest call to fetch policy

curl -u <username>:<password> -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://<HOSTNAME>:6080/service/public/v2/api/service/kmsdev/policy

Re: I am using HDP 2.4 Sandbox. I want to Create Policy in Apache Ranger through REST API call from web page. Request if I can get the API call syntax. Can I make the API call from HTML form POST method? Thanks Hari

New Contributor

Thanks Ramesh. Can you please suggest on how can I call this REST API from my webpage (using HTML/Javascript) ?

Re: I am using HDP 2.4 Sandbox. I want to Create Policy in Apache Ranger through REST API call from web page. Request if I can get the API call syntax. Can I make the API call from HTML form POST method? Thanks Hari

Explorer

@Hari Shankar Sudhakaran there are many ways to call REST APIs through javscript (angular has its way, there's jQuery, and others). It really depends what frameworks you are using.