VMware {code} Community
petermie
Enthusiast
Enthusiast

REST API for content library item not recognizing library ID

Hello,

I'm trying to use the REST API to deploy a content library template, but I'm having problems getting the item ID. If I do a GET to /api/content/library, I successfully get back a list of my libraries and if I do a GET to /api/content/library/{library_id} using one of the IDs I get back from /api/content/library I get details of that library ok so I know my library ID should be good. My problem is if I do a GET to /api/content/library/item?library_id using any of the IDs that work on the other GETs, I get back this:

{
    "error_type": "INVALID_ARGUMENT",
    "messages": [
        {
            "args": [
                "library_id"
            ],
            "default_message": "Invalid value for property with name: library_id.",
            "id": "com.vmware.vapi.rest.invalidProperty"
        }
    ]
}

and I have no idea why. All the documentation I read points to this should work fine but for some reason it doesn't. Do I need to use a different library ID somehow or prefix it somehow? It seems like the other arguments on /api/vcenter/vm-template/library-items/{template_library_item}?action=deploy use MoRefs but the IDs I'm getting back from /api/content/library are more like GUIDs?

0 Kudos
3 Replies
petermie
Enthusiast
Enthusiast

Found a bit of a workaround: if I post to /api/content/library/item?action=find with my content library ID, I get the item IDs in that content library and I can filter by name in the request (if I know it first) so I can work with that for my needs. I with I knew why getting to /api/content/library/item?library_id with my library ID doesn't work though

0 Kudos
StanGrigorov
Contributor
Contributor

I think it might be an API error as the argument should not be library_id but should be the actual library_id.

vsphere developer center suggests this curl command that gives the same error

curl -X GET 'https://vshpere_host.vsphere_domain/api/content/library/item?library_id&library_id=xxxxxxxxxx' -H 'vmware-api-session-id: yyyyyyyyy'

but the following line works ok

curl -X GET 'https://vshpere_host.vsphere_domain/api/content/library/item?library_id=xxxxxxxxxx' -H 'vmware-api-session-id: yyyyyyyyy'

 

0 Kudos
Nickyuerra
Contributor
Contributor

I have discovered a workaround: if I post to /api/content/library/item?action=find with my content library ID, I will get the item IDs that are included inside that content library. Additionally, I will be able to filter the request by name (provided that I am aware of the name beforehand), which will allow me to work with that for my requirements. Despite the fact that I am aware of the reason why accessing /api/content/library/item?library_id with my library ID does not function, I cannot.

geometry dash breeze

0 Kudos