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

locations/create - Request contains an invalid argument Error 400

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

While switching from API v3 to v4, creating locations doesn't work anymore, and returns only a generic error "Request contains an invalid argument".

 

I've replaced "setCountry" with "setRegionCode" as mentioned in the backwards-incompatible changes, and had to remove the parameter "languageCode" from the create call.

 

Is there any way to figure out what's going wrong here? Or to get some detailed error message?

 

 

$locationService = $this->service->accounts_locations;

$address = new Google_Service_MyBusiness_PostalAddress();
$address->setAddressLines('Ackerstraße 53');
$address->setPostalCode('47229');
$address->setLocality('Duisburg');
//$address->setCountry('DE');
$address->setRegionCode('DE');

$location = new Google_Service_MyBusiness_Location();
$location->setAddress($address);
$location->setLabels(['908507']);
$location->setPrimaryPhone('02065-6869678');
$location->setLocationName('Happe Sicherheitsdienste');
$location->setStoreCode('908507');
$location->setWebsiteUrl('https://happe-sicherheitsdienst.de');

$primaryCategory = new Google_Service_MyBusiness_Category();
$primaryCategory->setCategoryId('gcid:florist');
$location->setPrimaryCategory($primaryCategory);

$optParams = [];
//$optParams['languageCode'] = "de";
$optParams['validateOnly'] = false;
$optParams['requestId'] = uniqid();

$createdlocation = $locationService->create($accountName, $location, $optParams);
 

 

1 Expert replyverified_user

Re: locations/create - Request contains an invalid argument Error 400

Google Employee
# 2
Google Employee

Hi @Tanja G,

 

We suggest you follow the Make a simple HTTP request step-by-step guide on the Google Developers site and try use the OAuth 2.0 Playground to step through the auth flow, and examine the HTTP request/response at each step. This usually helps pinpoint where an application is passing the incorrect info.

 

Thanks,

The Google My Business API team

locations/create - Request contains an invalid argument Error 400

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

By trial and error, it turned out that the new API version needs lat/lng as required fields, which weren't required before.

 

The HTTP response doesn't mention it, neither does the changelog.

Experts in the Topic
Shalini S