Hi Robert, Seems like you are hitting wrong curl command.
To import policies you have to pass data-file with "-F" and in header set content type as multipart/form-data. correct curl: curl -i -X POST -H "Content-Type: multipart/form-data" -F 'file=@/filePath/ranger-polices.json' -u admin:admin " http://localhost:6080/service/plugins/policies/importPoliciesFromFile?isOverride=true &serviceType=hdfs,hive" Regard, Bhavik Patel +91-7208744109 On Mon, Apr 3, 2017 at 6:16 PM, Sean Roberts <[email protected]> wrote: > Ranger folks – Can you provide advice on importing policies via the API. > > > > I imported via UI and am trying to replicate the actions via curl but it > is not accepting it. The json is an export (attached) > > > > curl –v -u admin:admin \ > > -H Content-Type: application/json -X POST –d @ranger-policies.json \ > > "http://localhost:6080/service/plugins/policies/importPoliciesFromFile? > isOverride=true&serviceType=hdfs,hive" > > > > * About to connect() to localhost port 6080 (#0) > > * Trying 127.0.0.1... > > * Connected to localhost (127.0.0.1) port 6080 (#0) > > * Server auth using Basic with user 'admin' > > > POST /service/plugins/policies/importPoliciesFromFile? > isOverride=true&serviceType=hdfs,hive HTTP/1.1 > > > Authorization: Basic YWRtaW46YWRtaW4= > > > User-Agent: curl/7.29.0 > > > Host: localhost:6080 > > > Accept: */* > > > Content-Type: application/json > > > Content-Length: 4718 > > > Expect: 100-continue > > > > > < HTTP/1.1 100 Continue > > < HTTP/1.1 404 Not Found > > < Server: Apache-Coyote/1.1 > > < Set-Cookie: RANGERADMINSESSIONID=2CE00A4CA61EADCB0B491282E81608DE; > Path=/; HttpOnly > > < X-Frame-Options: DENY > > < Content-Length: 0 > > < Date: Mon, 03 Apr 2017 12:45:17 GMT > > < Connection: close > > < > > * Closing connection 0 > > > > -- > > Sean Roberts > > Partner Engineering, EMEA > > @seano > > >
