Required Parameter "resource" gets deleted in apirequest.js
I am trying to use API cloudresourcemanager.projects.getIamPolicy which expects "resource" as required parameter in the request. However, "delete params.resource;" statement in apirequest.js deletes this "resource" parameter and the request fails.
My code snippet is as follows: var params = { auth: googleClient, resource: project, fields: 'bindings' }; googleapis.cloudresourcemanager('v1').projects.getIamPolicy (params, function (err, roles) { });
This call to getIamPolicy fails as the resource parameter is deleted by apirequest.js Kindly fix this or suggest a workaround.
Thanks! Santosh
@tcoffee-google The example for getIamPolicy() looks ambiguous (specifically resource vs resource_) - can you take a look?
@sankulka Have you tried using resource_ (with an underscore at the end) instead of resource?
@ace-n is correct, the confusion is due to renaming in the Node.js client library (these libraries are autogenerated, and happen to use the name resource for the request body, so parameters named resource are renamed to resource_).
You can see a Node.js code example for this method in the last tab under "Examples" at https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/getIamPolicy .
Yes, resource_ worked well. In that case, the documentation/example should be modified stating resource_ is mandatory and it should remove "resource". The API Explorer should also remove resource and swap it with resource_.
Thanks, Santosh
It looks to me like the comments in the example for Node.js do indicate that resource_ is the required field. At present, the API Explorer and the remaining documentation on the reference page are not language-specific, and show the correct name for every other language, so it probably does not make sense to change these.
While it would be breaking to change the name of this field to something less conflict-prone, it would be helpful to add a warning in the situation you encountered. Filed https://github.com/google/google-api-nodejs-client/issues/721.