I am trying to get specific response from Compute API method instances.aggregatedList by setting the fields request param as per https://cloud.google.com/resource-manager/docs/performance#partial-response
But I am getting 400 BAD REQUEST.
Is there a sample which I can refer for getting partial response for aggregated methods?
If you use the following CURL command:
You'll notice that the result will have a similar form to:
As you can see the result is a little bit different as the response body explained in the documentation:
Notice that if you compare both results, the actual response that you receive has an additional
"zones/us-central1-a":field before theinstances:field that I believe is causing the behavior you experience.If you are interested in working with partial resources and get only some particular fields on the response you simply need to respect the syntax rules explained on the documentation you've shared and use the escape characters accordingly on your query parameters.
E.g. if you are only interested in getting the
idof your project as well as theinstances'name,machineTypeandstatusI tested the following curl command from the Cloud Shell with my GCP project and it worked without issues:where I see that something similar to the following is returned: