Ayub – Perfect. That works. Thanks! I also tried with ‘-F’ but had the wrong field name.
-- Sean Roberts Partner Engineering, EMEA @seano From: Ayub Khan Pathan <[email protected]> Date: Monday, 3 April 2017 at 15:21 To: "[email protected]" <[email protected]>, Sean Roberts <[email protected]> Subject: Re: Import policies via API Hi Sean, Can you try the exact below cmd? curl -v -X POST -u "admin:admin" \ -H "Content-Type: multipart/form-data" \ -H "Content-Type: application/json" \ -F 'file=@Ranger_Policies_20170403_131421.json' \ http://ctr-e129-1487033772569-66527-01-000002.hwx.site:6080/service/plugins/policies/importPoliciesFromFile?isOverride=true&serviceType=hive * Trying 172.27.23.199... * Connected to ctr-e129-1487033772569-66527-01-000002.hwx.site (172.27.23.199) port 6080 (#0) * Server auth using Basic with user 'admin' > POST > /service/plugins/policies/importPoliciesFromFile?isOverride=true&serviceType=hive > HTTP/1.1 > Host: ctr-e129-1487033772569-66527-01-000002.hwx.site:6080 > Authorization: Basic YWRtaW46YWRtaW4= > User-Agent: curl/7.43.0 > Accept: */* > Content-Length: 20050 > Expect: 100-continue > Content-Type: multipart/form-data; > boundary=------------------------054d9e8c1762dcd0 > < HTTP/1.1 100 Continue < HTTP/1.1 204 No Content < Server: Apache-Coyote/1.1 < Set-Cookie: RANGERADMINSESSIONID=A063D293277437D074EFD2435967EF88; Path=/; HttpOnly < WWW-Authenticate: Negotiate < Set-Cookie: hadoop.auth=; Path=/; Domain=ctr-e129-1487033772569-66527-01-000002.hwx.site; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly < X-Frame-Options: DENY < Content-Type: application/json < Date: Mon, 03 Apr 2017 13:15:53 GMT < * Connection #0 to host ctr-e129-1487033772569-66527-01-000002.hwx.site left intact Regards Ayub Khan From: Sean Roberts <[email protected]> Reply-To: "[email protected]" <[email protected]> Date: Monday, April 3, 2017 at 6:16 PM To: "[email protected]" <[email protected]> Subject: Import policies via API 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
