My Business
4.7K members online now
4.7K members online now
For developers who are using the Google My Business API to manage locations
Guide Me
star_border
Reply

Country Validation Issues on Location Create

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I'm trying out an approach (context below at the end of the message) that involves creating a location via accounts.location.create. I get a consistent validation error on the address.country field:

 

{ '@type': 'type.googleapis.com/google.mybusiness.v3.ValidationError',
errorDetails:
  [ { code: 2,
      field: 'address.country',
      message: 'address.country is required' } ] }


The location information I am sending in the POST body definitely has a country value in the correct ISO format:

 

{ locationName: 'Professional Video Production and Videography | Fresno Video Pros',
  primaryPhone: '5593249341',
  address:
  { addressLines: [ '200 West Bullard Avenue' ],
    subLocality: '',
    locality: 'Clovis',
    administrativeArea: 'CA',
    postalCode: '93612',

    country: 'US' },
  websiteUrl: 'http://www.fresnovideopros.com/',
  locationKey: { placeId: 'ChIJOQDdJYxclIARWEADKEQ56J8' } }

 

This error persists whether I send "validateOnly=true", or whether I include or exclude the locationKey.

 

Are there any other required fields or another reason the address validation might be failing?

 

If it's helpful, here are the full options, request details, and response values I get (note, these log details are emitted by the request.js library for node.js:

 

{ [Error: Expected one of [200], got 400]
  body:
  { error:
    { code: 400,
      message: 'Request contains an invalid argument.',
      status: 'INVALID_ARGUMENT',
      details: [Object] } },
  options:
    { url: 'https://mybusiness.googleapis.com:443/v3/accounts/REDACTED/locations',
      json: true,
      expects: [ 200 ],
      method: 'POST',
      data:
      { locationName: 'Professional Video Production and Videography | Fresno Video Pros',
        primaryPhone: '5593249341',
        address: [Object],
        websiteUrl: 'http://www.fresnovideopros.com/',
        locationKey: [Object] },
      qs:
      { validateOnly: true,
        requestId: '1472762648218',
        languageCode: 'en-US',
        access_token: 'REDACTED' },
      callback: [Function] } }

 

Context:

I wanted to keep the original request quite simple as there might be a simple fix. For what it's worth, here is the background and context of why I'm pursuing this angle. I believe I have a Place ID and Maps ID for a duplicate of my managed GMB location.

  • GMB location associated with Place ID ChIJOQDdJYxclIARylApRIcgMtM points to Maps ID: https://maps.google.com/?cid=15218261856174559434 (as ascertained by the Places API)
  • Duplicate Place ID ChIJOQDdJYxclIARWEADKEQ56J8 and Maps ID: https://maps.google.com/?cid=11522522611519275096
  • I am attempting to create a GMB location with the information of the 2nd location and associate it with the Place ID
  • Once created and associated, I want to work with Google to mark it as a duplicate and either merge, forward, or remove the listing

Solving the country validation issue would be interesting, but I'd be even more interested in learning if the GMB API could help me flag listings as duplicates for review and processing by Google.

 

Thanks!

 

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author David P
February 2017

Re: Country Validation Issues on Location Create

Google Employee
# 3
Google Employee

Hi @David P,

 

When I sent a POST request to create a new location with the JSON request body that you included in your post, I received the following ValidationError in the JSON response body:

{

 "error": {

   "status": "INVALID_ARGUMENT",

   "message": "Request contains an invalid argument.",

   "code": 400,

   "details": [

     {

       "errorDetails": [

         {

           "field": "primary_category",

           "message": "primary_category is required",

           "code": 2

         }

       ],

       "@type": "type.googleapis.com/google.mybusiness.v3.ValidationError"

     }

   ]

 }

}

 

I supplied the required categoryId of the Category object in the primaryCategory field for the POST request and received the 200 OK status code with the following Location object in the JSON response body:

{

 "websiteUrl": "http://www.fresnovideopros.com/",

 "openInfo": {

   "status": "OPEN"

 },

 "locationKey": {

   "placeId": "ChIJOQDdJYxclIARWEADKEQ56J8"

 },

 "specialHours": {},

 "primaryCategory": {

   "name": "Video Production Service",

   "categoryId": "gcid:video_production_service"

 },

 "locationName": "Professional Video Production and Videography | Fresno Video Pros",

 "photos": {},

 "primaryPhone": "(559) 324-9341",

 "address": {

   "postalCode": "93612",

   "country": "US",

   "administrativeArea": "CA",

   "addressLines": [

     "200 West Bullard Avenue"

   ],

   "locality": "Clovis"

 },

 "regularHours": {}

}

 

The above JSON dump for the Location object should fix your first problem. I suggest you follow the Make a simple HTTP request step-by-step guide on the Google Developers site to learn how to use the OAuth 2.0 Playground for troubleshooting errors with detailed error messages when sending requests with data via the Google My Business API.

 

For your second problem, I see in our internal system that the two Maps listings you provided in your post have different primary owners. When you verify your local business on Google, you may have to contact the current listing owner if someone else verified your business. Once you have resolved ownership conflicts and become the owner of the listing, you can mark the duplicate location as permanently closed and report the duplicate location on Google Maps.

 

Thanks,

Terry

View solution in original post

Re: Country Validation Issues on Location Create

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

I found an older question similar to mine regarding problems with the country validation on location create: https://www.en.advertisercommunity.com/t5/Google-My-Business-API/Getting-field-error-from-API-when-s...

 

I'll try out the troubleshooting steps there. However, my reason for confidence in the provided address components is that they were copied out directly from the Places API response for that Place ID; these should be valid and accepted address values for Google because they came from Google.

 

Either way, I'd appreciate some troubleshooting steps or further investigation into this one.

Marked as Best Answer.
Solution
Accepted by topic author David P
February 2017

Re: Country Validation Issues on Location Create

Google Employee
# 3
Google Employee

Hi @David P,

 

When I sent a POST request to create a new location with the JSON request body that you included in your post, I received the following ValidationError in the JSON response body:

{

 "error": {

   "status": "INVALID_ARGUMENT",

   "message": "Request contains an invalid argument.",

   "code": 400,

   "details": [

     {

       "errorDetails": [

         {

           "field": "primary_category",

           "message": "primary_category is required",

           "code": 2

         }

       ],

       "@type": "type.googleapis.com/google.mybusiness.v3.ValidationError"

     }

   ]

 }

}

 

I supplied the required categoryId of the Category object in the primaryCategory field for the POST request and received the 200 OK status code with the following Location object in the JSON response body:

{

 "websiteUrl": "http://www.fresnovideopros.com/",

 "openInfo": {

   "status": "OPEN"

 },

 "locationKey": {

   "placeId": "ChIJOQDdJYxclIARWEADKEQ56J8"

 },

 "specialHours": {},

 "primaryCategory": {

   "name": "Video Production Service",

   "categoryId": "gcid:video_production_service"

 },

 "locationName": "Professional Video Production and Videography | Fresno Video Pros",

 "photos": {},

 "primaryPhone": "(559) 324-9341",

 "address": {

   "postalCode": "93612",

   "country": "US",

   "administrativeArea": "CA",

   "addressLines": [

     "200 West Bullard Avenue"

   ],

   "locality": "Clovis"

 },

 "regularHours": {}

}

 

The above JSON dump for the Location object should fix your first problem. I suggest you follow the Make a simple HTTP request step-by-step guide on the Google Developers site to learn how to use the OAuth 2.0 Playground for troubleshooting errors with detailed error messages when sending requests with data via the Google My Business API.

 

For your second problem, I see in our internal system that the two Maps listings you provided in your post have different primary owners. When you verify your local business on Google, you may have to contact the current listing owner if someone else verified your business. Once you have resolved ownership conflicts and become the owner of the listing, you can mark the duplicate location as permanently closed and report the duplicate location on Google Maps.

 

Thanks,

Terry