1
votes

I am trying to manually write a log entry using Google Cloud Logging API.

Before doing this via code, I am first trying to do it using the Google APIs Explorer. Here is a screen shot of the request I've built using this tool:

Screenshot

  • In projectsId I have the Google Project Id that I've copied from the Google Developer Console.
  • Likewise for metadata.projectId.
  • In metadata.userId I have the Client Id of the same Service account that I'm using to authenticate (OAuth2) against the Google Logging API.
  • Google Logging API is enabled for the project.
  • The Service account belong to the project and has the "Can edit" permission.
  • I'm 99% sure that I've setup OAuth2 correctly for the request.

When I execute this request, I get the following response:

{
  "error": 
  {
    "code": 400,
    "message": "Unsupported service specified",
    "status": "INVALID_ARGUMENT"
  }
}

Why? and how can I fix this?

1

1 Answers

1
votes

The error message was actually telling me exactly which argument was invalid - The serviceName I supplied was bogus ("test").

As soon as I set the serviceName to be "compute.googleapis.com", the problem went away and I received a 200 status code indicating success.