VMware Cloud Community
onboard
Enthusiast
Enthusiast

Update vRO Ressource Item with description via PowerShell

Hi,

I am trying to update a vRealize Orchestrator Ressource Item with a powershell script. I did manage to update the ressource item, but I did not manage to update the Item with a valid description.

Does anyone know how to do this?

The script code I use, is:

$fileName = "adGroup.txt"

$uri = "https://vroadress/vco/api/resources/id"

$currentPath = "c:\test"

$filePath="$currentPath\$fileName"

$fileBin = [System.IO.File]::ReadAlltext($filePath)

$boundary = [System.Guid]::NewGuid().ToString()

$LF = "`r`n"

$bodyLines = (

       "--$boundary",

       "Content-Disposition: form-data; name=`"file`"; filename=`"$fileName`"",

       "Content-Type: application/octet-stream$LF",

       $fileBin,

       "--$boundary--$LF"

) -join $LF

Invoke-RestMethod -Uri $uri -Method Post -ContentType "multipart/form-data; boundary=`"$boundary`"" -Body $bodyLines -Credential $cred

pastedImage_4.png

I would like to update the description, so I can give some info about where it was updated from. If I do the update manually through the GUI of vRO it updates fine with a path.

Hope someone can push my in the right direction.

Christian

Reply
0 Kudos
8 Replies
iiliev
VMware Employee
VMware Employee

Hi,

Updating resource's description/version/name is done with a different REST API call:

PUT https://{vroaddress}/vco/api/resources/{id}

Reply
0 Kudos
onboard
Enthusiast
Enthusiast

Hi,

Could you put together a simple example, how this would work? Postman gives me a "Method Not Allowed" and under Headers\Allow returned, it gives the follow -> DELETE, POST, GET.

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

Which version/build number of vRO do you use?

I forgot to mention that this is a relatively new API (from January this year, so probably it is available only in vRO 8.1 and latest service pack builds of vRO 8.0.1 (not sure about 7.x).

Reply
0 Kudos
onboard
Enthusiast
Enthusiast

I am using a vRA 7.5 embedded vRO. So if is only supported in 8.x that will not work. I was just pretty sure, that there should be a way to add the description also, when it is being added when doing it manually.

In the case actually POST kinda works like a PUT, as the POST needs the id of the Ressource Item, only I was unsure if I could include the description in the multipart/form-data, so it would go along with file, I am uploading.


The Swagger UI does not include any PUTs under the ressources branch. So what to do? Smiley Happy

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

The java client in 7.x does not use REST API to communicate with vRO server, so it can do some things even they are not exposed to REST.

This particular POST request is not the same as the PUT request added to update resources. You cannot include the description in the multipart data payload if the API is not designed to fetch it from there.

So currently your options are one of the following:

  • update to 8.1
  • open a support request for this API to be back-ported to 7.x and delivered with next 7.x service pack builds
Reply
0 Kudos
onboard
Enthusiast
Enthusiast

Thanks a lot for your help. Java does not use REST, but would have been smart to expose the option of updating the description for REST API.

We will eventually upgrade to a newer version, so seem to be the most obvious choice. Not sure how much they are willing to backport to older versions.

Reply
0 Kudos
eoinbyrne
Expert
Expert

An additional though long-winded approach to get what you want until you upgrade would be to create a workflow as shown here (tested just now on 7.5 and it worked..)

pastedImage_0.png

Result looks like this (after I ran it twice in succession)

pastedImage_1.png

So, you could create a similar workflow with inputs to identify the ResourceElement to update & the description string to set, then execute it using REST from PowerShell

It's ugly but gets you where you want to go Smiley Happy

Reply
0 Kudos
onboard
Enthusiast
Enthusiast

That will put me in the right direction. Your are right it is ugly, but sure will do the task Smiley Happy.

Thx for the alternative input. I think it will create a simply workflows as you suggest and afterwards invoke that from the REST interface.

Reply
0 Kudos