Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag to remove odata.context in response #331

Closed
JasonRatcliffe opened this issue Sep 7, 2023 · 2 comments
Closed

Flag to remove odata.context in response #331

JasonRatcliffe opened this issue Sep 7, 2023 · 2 comments

Comments

@JasonRatcliffe
Copy link

Any command that is run utilizing mgz on a mac, the output always contains @odata.context within the json response.

Below is an example

mgc organization list --select "DisplayName, City, State, Country, PostalCode, BusinessPhones"

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#organization(displayName,city,state,country,postalCode,businessPhones)",
  "value": [
    {
      "displayName": "My Test Tenant",
      "city": "Beverly HIlls",
      "state": "CA",
      "country": null,
      "postalCode": "12345-0001",
      "businessPhones": [
        "1123 5551234"
      ]
    }
  ]
}

I have also tried doing the following with the same results.

mgc organization list --select "DisplayName, City, State, Country, PostalCode, BusinessPhones" --headers odata.metadata=full

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#organization(displayName,city,state,country,postalCode,businessPhones)",
  "value": [
    {
      "displayName": "My Test Tenant",
      "city": "Beverly HIlls",
      "state": "CA",
      "country": null,
      "postalCode": "12345-0001",
      "businessPhones": [
        "1123 5551234"
      ]
    }
  ]
}

The docs don't really provide any information on how to get this removed

@calebkiage
Copy link
Collaborator

Hello, thank you for raising this issue. The MSGraph API is built on OData and @odata.context is a standard part of response objects.

You can use the CLI's JMESPath support to perform transformations on the response from the server. JMESPath queries are provided by the --query option.

To get only the values array from the response, you can run:

mgc organization list --select "DisplayName, City, State, Country, PostalCode, BusinessPhones" --query values

Let me know if you need any further assistance.

@JasonRatcliffe
Copy link
Author

Understood, thank you @calebkiage . This will get me going for now. I appreciate the quick response and help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants