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

How to sent X-GOOG-API-FORMAT-VERSION to get more information in error response? #16520

Open
mkalkowski83 opened this issue Mar 23, 2023 · 3 comments
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@mkalkowski83
Copy link

mkalkowski83 commented Mar 23, 2023

Dear team,
I'm trying to use an extra header that is written in this documentation https://developers.google.com/my-business/samples/#detailed_error_responses but it doesn't work. Below is my code:

val create = apiFactory
     .createBusinessInformationClient()
     .Accounts()
     .Locations()
     .create("accounts/{account_id}",
    Location()
// .setTitle("Test shop by API") - I comment this because I want to get an error about missing field
        .setLanguageCode("pl")
        .setCategories(Categories().setPrimaryCategory(Category().setName("categories/gcid:aadhar_center")))
        .setStorefrontAddress(
            PostalAddress()
           .setLanguageCode("en")
           .setAddressLines(listOf("Tagore 1"))
           .setLocality("Warsaw")
           .setPostalCode("00-123")
          .setRegionCode("PL")
      )
      .setOpenInfo(
          OpenInfo().setStatus("OPEN")
       )
       .setProfile(Profile().setDescription("Ale super sklep"))
  )
create.requestHeaders.set("X-GOOG-API-FORMAT-VERSION", "2")
create.validateOnly = true
create.execute()

only what I get from the response is:

{
  "code": 400,
  "details": [
    {
      "@type": "[type.googleapis.com/google.rpc.BadRequest](http://type.googleapis.com/google.rpc.BadRequest)"
    }
  ],
  "errors": [
    {
      "domain": "global",
      "message": "Request contains an invalid argument.",
      "reason": "badRequest"
    }
  ],
  "message": "Request contains an invalid argument.",
  "status": "INVALID_ARGUMENT"
}

What I'm doing wrong?
Best Regards

@emmileaf
Copy link
Contributor

Can you provide more details on what API and maven artifact you are using (as well as any additional information you can share as outlined in the issues template)? Thanks!

@emmileaf emmileaf added type: question Request for information or clarification. Not an issue. priority: p3 Desirable enhancement or fix. May not be included in next release. labels Mar 24, 2023
@mkalkowski83
Copy link
Author

Hi @emmileaf
sure, more details are below:

Environment details
Google MyBusiness Business Information

OS type and version:
Java version:

openjdk version "18.0.2-ea" 2022-07-19
OpenJDK Runtime Environment (build 18.0.2-ea+9-Ubuntu-222.04)
OpenJDK 64-Bit Server VM (build 18.0.2-ea+9-Ubuntu-222.04, mixed mode, sharing)

Libs versions:

implementation("com.google.api-client:google-api-client:1.35.2")
implementation("com.google.auth:google-auth-library-oauth2-http:1.16.0")
implementation("com.google.apis:google-api-services-mybusinessbusinessinformation:v1-rev20221124-2.0.0")

Code example

val create = apiFactory
     .createBusinessInformationClient()
     .Accounts()
     .Locations()
     .create("accounts/{account_id}",
    Location()
// .setTitle("Test shop by API") - I comment this because I want to get an error about missing field
        .setLanguageCode("pl")
        .setCategories(Categories().setPrimaryCategory(Category().setName("categories/gcid:aadhar_center")))
        .setStorefrontAddress(
            PostalAddress()
           .setLanguageCode("en")
           .setAddressLines(listOf("Tagore 1"))
           .setLocality("Warsaw")
           .setPostalCode("00-123")
          .setRegionCode("PL")
      )
      .setOpenInfo(
          OpenInfo().setStatus("OPEN")
       )
       .setProfile(Profile().setDescription("Ale super sklep"))
  )
create.requestHeaders.set("X-GOOG-API-FORMAT-VERSION", "2")
create.validateOnly = true
create.execute()

Stack trace

{
  "code": 400,
  "details": [
    {
      "@type": "[type.googleapis.com/google.rpc.BadRequest](http://type.googleapis.com/google.rpc.BadRequest)"
    }
  ],
  "errors": [
    {
      "domain": "global",
      "message": "Request contains an invalid argument.",
      "reason": "badRequest"
    }
  ],
  "message": "Request contains an invalid argument.",
  "status": "INVALID_ARGUMENT"
}

External references such as API reference guides: https://developers.google.com/my-business/samples/#detailed_error_responses

@diegomarquezp diegomarquezp added type: question Request for information or clarification. Not an issue. and removed type: question Request for information or clarification. Not an issue. labels Sep 5, 2024
@burkedavison burkedavison added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed type: question Request for information or clarification. Not an issue. labels Sep 16, 2024
@burkedavison
Copy link
Member

Improve documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

4 participants