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

Request contains an invalid argument. [400] - Create Location

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

Hello,

 

I am getting the “Request contains an invalid argument. [400]” . The following is code (Google.Apis.MyBusiness.v3) in c#

 

Location loc = new Location();
            loc.AdditionalCategories = additional.ToList();
            loc.AdditionalPhones = new List<string>() { store.AdditionalTelephone };
            loc.Address = new Address
            {
                AddressLines = new List<string>() { store.AddressLine1},
                AdministrativeArea = store.AdministrativeArea, //string.Format("{0}-{1}", store.Country, store.AdministrativeArea),
                Country = store.Country,
                Locality = store.Locality,
                PostalCode = store.PostalCode,
                SubLocality = store.SubLocality
            };
            loc.AdWordsLocationExtensions = new AdWordsLocationExtensions() { AdPhone = store.AdWordsPhoneExtension };
            loc.LanguageCode = "IT";
            loc.Latlng = new LatLng() { Latitude = store.Latitude, Longitude = store.Longitude };
            //loc.LocationName = store.BusinessName;
            //loc.Name = accountName;
            //loc.Photos
            //loc.PriceLists
            loc.PrimaryCategory = primary;
            loc.PrimaryPhone = store.PrimaryTelephone;
            loc.RegularHours = new BusinessHours() { Periods = new List<TimePeriod>() { new TimePeriod() { OpenDay = "MONDAY", CloseDay = "MONDAY", OpenTime = "09:00", CloseTime = "21:00" } } };
            //loc.ServiceArea.
            //loc.SpecialHours
            loc.StoreCode = store.StoreCode;
            loc.WebsiteUrl = store.WebSite;
            var locRequest = m_service.Accounts.Locations.Create(loc, accountName);
            locRequest.LanguageCode = "IT";
            locRequest.RequestId = Guid.NewGuid().ToString();
            locRequest.ValidateOnly = true;


            var jsonLoc = JsonConvert.SerializeObject(loc);
            return await locRequest.ExecuteAsync();

 

As suggested on some other posts I tried using OAuth 2.0 Playgorund (json I extracted from code by serializing the location object), I had the following problems

 

  1. The json string contains "ETag": null in all the properties, I have to remove manually before using in OAuth playground (on client library I see there is no JsonIgnoreAttribute for ETag property ??? :() otherwise I get "Invalid JSON payload received. Unknown name \"e_tag\" error
  2. After removing all ETag from json , I receive the following error on OAuth 2.0 Playgorund

{

  "error": {

    "status": "NOT_FOUND",

    "message": "Requested entity was not found.",

    "code": 404

  }

}

 

Can anyone shed some light on this?

 

The following is the json code

 

{
	"adWordsLocationExtensions": {
		"adPhone": ""
	},
	"additionalCategories": [{
		"categoryId": "gcid:furnishing_supplier",
		"name": "Arredamento"
	},
	{
		"categoryId": "gcid:fabric_store",
		"name": "Negozio di tessuti"
	},
	{
		"categoryId": "gcid:gift_shop",
		"name": "Negozio di articoli da regalo"
	},
	{
		"categoryId": "gcid:novelty_store",
		"name": "Negozio di articoli da regalo"
	}],
	"additionalPhones": [""],
	"address": {
		"addressLines": ["Viale Cassiodoro, 17"],
		"administrativeArea": "CZ",
		"country": "IT",
		"locality": "Catanzaro",
		"postalCode": "88100",
		"subLocality": ""
	},
	"attributes": null,
	"labels": null,
	"languageCode": "IT",
	"latlng": {
		"latitude": 38.8840151,
		"longitude": 16.6035239
	},
	"locationKey": null,
	"locationName": null,
	"locationState": null,
	"metadata": null,
	"name": null,
	"openInfo": null,
	"photos": null,
	"priceLists": null,
	"primaryCategory": {
		"categoryId": "gcid:home_goods_store",
		"name": "Casalinghi"
	},
	"primaryPhone": "0961 63590",
	"regularHours": {
		"periods": [{
			"closeDay": "MONDAY",
			"closeTime": "21:00",
			"openDay": "MONDAY",
			"openTime": "09:00",
		}]
	},
	"serviceArea": null,
	"specialHours": null,
	"storeCode": "A003",
	"websiteUrl": "http://wwww.kasanova.it"
}

 

Thanks in advance,

Holy

1 Expert replyverified_user

Re: Request contains an invalid argument. [400] - Create Location

Google Employee
# 2
Google Employee

Hi @kasanova k,

 

The 404 Method not found error typically happens when you are using a different Project ID from the one we whitelisted for your company to access the Google My Business API.

 

We’ll reach out to you privately in a separate email thread for more details.

 

Thanks,

The Google My Business API team

Request contains an invalid argument. [400] - Create Location

[ Edited ]
Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi,

 

I have replied on the seperate email thread as you requested.

But the strange behaviour I noticed is that I could able to access the data via oAuthPlayGround but not in Google My Business API via Service Account

 

More over the account Name I access via oAuthPlayGround is different from in Google My Business API via Service Account name

 

Account Name via oAuthPlayGround

{

  "accounts": [

    {

      "state": {

        "status": "VERIFICATION_REQUESTED"

      },

      "type": "PERSONAL",

      "name": "accounts/103836632594951002329",

      "accountName": "kasanova kasanova"

    }

  ]

}

 

Account Name via GMB

accounts/104292285077081620531

 

Is it normal? Or Is it the problem related to the way I access GMB API via service account

 

Thanks in advance,

Holy

 

Re: Request contains an invalid argument. [400] - Create Location

Google Employee
# 4
Google Employee

Hi @kasanova k,

 

If you are building a service account application, the following are the required steps you should take for the service account application to work with the Google My Business API:

        

$user_to_impersonate = 'user@example.org';
        $cred = new Google_Auth_AssertionCredentials(
          $client_email,
          array('https://www.googleapis.com/auth/plus.business.manage'),
          $key,
          'notasecret',                                 // Default P12 password
          'http://oauth.net/grant_type/jwt/1.0/bearer', // Default grant type
          $user_to_impersonate
        );

 

You should be able to get your service account application to work after you’ve applied the above steps. I hope this helps!

 

Thanks,

Shalini, Google My Business API team