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

PATCH Request Error: "Request contains an invalid argument" without description

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

Hi everyone.

 

When I do some simple code:

 

 

$location = new Google_Service_Mybusiness_Location();
$location->primaryPhone = "(201) 555-5555";
$fieldMask[] = 'primaryPhone';
    
if($fieldMask) {
  $myBusiness->accounts_locations->patch($locationName, $location, array(
    'fieldMask' => implode(',', $fieldMask),
  ));
}

I get error without description:

 

 

{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "errors": [
      {
        "message": "Request contains an invalid argument.",
        "domain": "global",
        "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

But if I change phone to (082) 489-3671, it's working. I understand, that this phone is not correct for location city, but where can I get more description about it? I need to create user interface for editing this field, and need to validate this field. How can I do it?

 

This applies to all other fields, for example: country, addressLines, subLocality, locality, administrativeArea, postalCode, websiteUrl. I have the same problem when I fill field by incorrect data. But what is incorrect I don't know. Please, help me.

1 Expert replyverified_user

Re: PATCH Request Error: "Request contains an invalid argument" without description

Google Employee
# 2
Google Employee

Hi @Кирилл Л,

 

According to our Google My Business guidelines, the primary phone number should be:  

  • The best phone number customers can reach the business
  • can be mobile device or landline
  • cannot be a fax
  • must be valid in country the business is located in

I suggest you checkout this article for information about address format.

 

Thanks,

Shalini, The Google My Business API team

PATCH Request Error: "Request contains an invalid argument" without description

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi @Shalini S, and thank you for replying.

 

I mean something other. I will try to describe it.

I have form on my site, this form contains all location field (website, phone and address). It's needed to update current location by API. It will be doing by regular user (manager). This form does not communicate with user now, when error occurred (when user fill field by incorrect values). I mean form does not say what error was occured and it does not save any data when it happen. It has not usability for user. And user should search what he do wrong and spend his time.

 

I think I need to validate this field on side of my site but I don't know correct format for each field and any documentation does not provide it. Or I need to use Google validation for putting occurred error messages for user, but now Google API returns every time the same error message: "Request contains an invalid argument" and nothing else.

 

For example phone number and postal code have specific format, it depends on locality. I need system that can validate each field and it format and can give me error messages. 

 

Thanks.

Marked as Best Answer.
Solution
Accepted by topic author Кирилл Л
2d

PATCH Request Error: "Request contains an invalid argument" without description

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Hi,

 

From working with the API the past few weeks - it would appear that the current version of the API will not give you detailed exception messages. So it will not be able to tell you what particular fields are incorrect in your patch request, which isn't particularly helpful. If you submit your patch request with a specific field mask then at least you can narrow it down to being "something" wrong with the items you specified in the field mask. 

Experts in the Topic
Shalini S