Highlighted
Contributor
Contributor

Impossible to export VM properties in a convenient format

Hello,

I am developping a workflow to export VM properties. This workflow must be used used by API calls. The output type is "array of Properties .The problem is that the properties in the json we get with the API call (/catalog-service/api/consumer/requests/{idRequest}/forms/details) is in the format :

{  "key": "vmName" ,"value" : {"type":"string","value" :"MyVirtualMachine"} }

The format I expected was : { "vmName" : "myVirtualMachine"}.

The size is greatly increased and it becomes far more difficult to read. If I "stringify" the json directly on vRO I get the right format. I also tried to send the stringified json as well (by changing workflow ouptut type) but it was extracted by API with "\" before each special character. The backslashes were unvisible on vRO before the API call so I cannot remove it.

I searched on the Internet but I couldn't find any satisfying solution.

Do you know how I can send the properties or which API call I can use to solve the problem ?

Thank you in advance.

4 Replies
Highlighted
Expert
Expert

Hi EleK47

This may help

Accessing Custom Properties of a VM via REST API

If you think your queries have been answered
Marking this response as "Correct" or "Helpful"
ASAJM
Highlighted
Contributor
Contributor

Thank you, I'll take a look !

0 Kudos
Highlighted
Expert
Expert

And this

View Machine Details Example

If you think your queries have been answered
Marking this response as "Correct" or "Helpful"
ASAJM
0 Kudos
Highlighted
Virtuoso
Virtuoso

Since you know the format of the response all you need to do is a quick extraction and pass that on to your api call.  If you are getting back:

{  "key": "vmName" ,"value" : {"type":"string","value" :"MyVirtualMachine"} }

just do something like this:

var passThisValueToApi = JSON.parse(whateverVariableHoldsYourResponse).value.value;

0 Kudos