API Option list with Morpheus API URL and Parameters

Hello,

I am trying to call back Morpheus API with parameters for Nutanix Prism categories which need to use in service catalog. I am not getting any data. I can get data if I call to other API without parameters.

This is API URL with parameters > https://morpheus/api/options/typeahead?optionTypeId=2258&zoneId=1&cloudId=1&siteId=1

This is json respond body.

{
“success”: true,
“data”: [
{
“name”: “AppTier:Default”,
“value”: “AppTier:Default”
},
{
“name”: “AppTier:Testing_App_Tier”,
“value”: “AppTier:Testing_App_Tier”
},
{
“name”: “AppType:Apache_Spark”,
“value”: “AppType:Apache_Spark”
}
]
}

Here is my translation script.

results = ;
for (let i = 0; i < data.success.length; i++){
results.push({
name : data.data[i].name,
value : data.data[i].value
})
}

In your translation script, instead of data.success.length will data.length get you results?

Instead of data.success.length use data.data.length

3 Likes

Thank you so much, it worked.

Ah, very good catch @dgaharwar. Double data