Hot Shot
Hot Shot

vRA 8.1 - iaas rest api returning "Invalid mime type" error

Jump to solution

I've been trying to extract a response from the vRA 8.1 iaas API, with no luck so far. every API call to, for example https://$url/iaas/api/about returns, the error:

{"timestamp":1603193804909,"path":"/iaas/api/about","status":500,"error":"Internal Server Error","message":"Invalid mime type \"org.mozilla.javascript.Undefined@ac577ae\": does not contain '/'","requestId":"3bca07fd","@type":"org.springframework.http.InvalidMediaTypeException","cause":{"message":"Invalid mime type \"org.mozilla.javascript.Undefined@ac577ae\": does not contain '/'","@type":"org.springframework.util.InvalidMimeTypeException"}}

Normally I do not use an Accept or Content-Type header to force a specific content type and am relying on application/json. This works fine with other API requests like:

https://$url/blueprint/api/about or

https://$url/deployment/api/deployments

Including the Accept and/or Content-Type header with the value "application/json" returns the same error as above.

Does the iaas API request a specific schema or is this a bug?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Hot Shot
Hot Shot

This one worked for me:

request = restHost.createRequest("GET", "iaas/api/tags");

request.contentType = "application/json";

request.setHeader("Authorization", "Bearer " + access_token);

request.setHeader("Accept", "application/json");

response = request.execute();

System.log(response.contentAsString);

View solution in original post

0 Kudos
4 Replies
Hot Shot
Hot Shot

curl -k -s -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "https://vra8.corp.local/iaas/api/tags"
worked fine for me.

0 Kudos
Hot Shot
Hot Shot

I've checked again and yes, makign the call with curl does work...

What drives me mad is, that I cannot seem to get it to work in vRO, I've created a transient host using all the required parameters and simply cannot get it to execute properly.

Swapping from /iaas/api/about to /blueprint/api/about or any other API does work. I get the issue only when accessing the iaas API Smiley Sad

0 Kudos
Hot Shot
Hot Shot

This one worked for me:

request = restHost.createRequest("GET", "iaas/api/tags");

request.contentType = "application/json";

request.setHeader("Authorization", "Bearer " + access_token);

request.setHeader("Accept", "application/json");

response = request.execute();

System.log(response.contentAsString);

View solution in original post

0 Kudos
Hot Shot
Hot Shot

Thanks for the tip, I have noticed where the error was - when building the rest host object, I have added the content type as a header: "Content-Type: application/json".

This does not seem to work with the iaas API, but does for the other ones, this was the confusing part.

Adding the content type to the rest request object using .contentType = "application/json" did the trick.

0 Kudos