Accessing Role from Group via API

Hello,

A simple request to get a list of groups with their roles:
https://{{hostname}}/api/groups?expand=resources&attributes=id,role

Returns following error:

{
“error”: {
“kind”: “bad_request”,
“message”: “Invalid attributes specified: role”,
“klass”: “Api::BadRequestError”
}
}

Group should normally have relationships to role and tenant according to the doc here.

Whereas the same request with tenant works well:
https://{{hostname}}/api/groups?expand=resources&attributes=id,tenant

Have I missed anything here?

Hi

Try:

/api/groups?expand=resources&attributes=id,miq_user_role

Useful tip, making an OPTIONS call to the collection lists all of the available options, for example:

OPTIONS https://<miq>/api/groups

lists everything that’s valid for groups , so in this case valid relationships shows…

...
    "relationships": [
        "active_vms",
        "authentications",
        "custom_action_buttons",
        "custom_actions",
        "custom_attributes",
        "custom_button_events",
        "custom_button_sets",
        "custom_buttons",
        "entitlement",
        "external_urls",
        "miq_custom_attributes",
        "miq_product_features",
        "miq_report_results",
        "miq_reports",
        "miq_templates",
        "miq_user_role",
...

Hope this helps,
pemcg

Hi Peter,

Thank you. That’s exactly what I was looking for. Good point on OPTIONS call.

Best regards,