Artifactory: create permission via api fails with "HTTP 405 method not allowed"

47 Views Asked by At

After reading the official Documentation about creating permissions

I've copied the sample data from the site and place it in test.json (and fixed the missing } at the end in order to have a valid json file.)

Then the following command failed:

curl -X POST 'http://localhost:8082/access/api/v2/permissions/Checkmate.json' --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer eyJ2ZXIiOi...' -d @test.json

leads to:

{
  "errors" : [ {
    "code" : "METHOD_NOT_ALLOWED",
    "message" : "HTTP 405 Method Not Allowed"
  } ]
}

I've tried the delete permissions example and that worked with the same bearer token.

What am I doing wrong - the documentation is not precise enough.

PS: running artifactory version 7.77.5

1

There are 1 best solutions below

1
Gajapathi Kimidi On BEST ANSWER

I created a file called my-test.json with below content

{
   "name": "my-test",
   "resources": {
       "artifact": {
           "actions": {
               "users": {user1},
               "groups": {
                   "mygroup" : [ "ANNOTATE", "WRITE", "READ" ]
               }
           },
           "targets": {
               "mytest": {}
           }
       }
   }
}

Then I ran the below command.

curl -v -X POST -H "Authorization: Bearer XXXXX" -H "Content-Type: application/json" -T my-test.json https://myartifactory.jfrog.io/access/api/v2/permission

My permission target was created successfully. Please give a try with this command.