HPE Morpheus Enterprise
1834463 Members
2588 Online
110067 Solutions
New Discussion

Re: API Option list with Morpheus API URL and Parameters

 
SOLVED
Go to solution
AungKT
Regular Advisor

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
})
}

4 REPLIES 4
Ollie-Phillips
Trusted Contributor

Re: API Option list with Morpheus API URL and Parameters

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

AungKT
Regular Advisor

Re: API Option list with Morpheus API URL and Parameters

Thank you so much, it worked.

Ollie-Phillips
Trusted Contributor

Re: API Option list with Morpheus API URL and Parameters

Ah, very good catch @dgaharwar. Double data

dgaharwar
Trusted Contributor
Solution

Re: API Option list with Morpheus API URL and Parameters

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