vCenter

 View Only
  • 1.  Content library creation from Rest api fails with 403 forbidden

    Posted Jun 08, 2021 04:20 AM

    i am trying to create content library using rest api. below is my payload. 

    url = https://{{vc}}/rest/com/vmware/content/local-library

    payload = 

    {
    "create_spec": {
    "name": "CL2",
    "description": "CL1 Desc",
    "publish_info": {
    "authentication_method": "NONE",
    "persist_json_enabled": false,
    "published": false
    },
    "storage_backings": [
    {
    "datastore_id": "datastore-12",
    "type": "DATASTORE"
    }
    ],
    "type": "LOCAL"
    }
    }
     
    though i am able to create content library using GUI, with this request i am facing unauthorized error as below
     
    {
    "type": "com.vmware.vapi.std.errors.unauthorized",
    "value": {
    "error_type": "UNAUTHORIZED",
    "messages": [
    {
    "args": [],
    "default_message": "Permission to perform this operation was denied.",
    "id": "com.vmware.vdcs.vsphere-auth-lib.permission.denied"
    }
    ]
    }
    }


  • 2.  RE: Content library creation from Rest api fails with 403 forbidden
    Best Answer

    Posted Jun 10, 2021 08:02 AM

    the issue was with datastore id , not with the permission. i gave the datastore name, instead of id, which caused this.

    the error was misleading though