AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

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

Create location in v3 error - primary_category.CATEGORY_ID is required

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

I've been playing with v3 today but have been unable to create a location. I'm setting the primary category just like in the code samples:

 

Location location = new Location()
.setAddress(address)
.setLocationName(businessName)
.setWebsiteUrl(siteUrl)
.setPrimaryPhone(phoneNumber)
.setLabels(Arrays.asList(buildLocationAccountLabel(accountVID), buildLocationCampaignLabel(campaignVID)))
.setPrimaryCategory(new Category().setName("Software Company"));

 

But keep receiving the following error even though the primary category is set, I agree the category ID is not set but I don't know the id for "Software Company" or how to get it??

 

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"message" : "Request contains an invalid argument.",
"status" : "INVALID_ARGUMENT",
"details" : [ {
"@type" : "type.googleapis.com/google.mybusiness.v3.ValidationError",
"errorDetails" : [ {
"code" : 2,
"field" : "primary_category.CATEGORY_ID",
"message" : "primary_category.CATEGORY_ID is required"
} ]
} ]
}

 

The documentation would seem to indicate the field is optional:

 

A stable ID (provided by Google) for this category. While it is possible to populate only thename field in a category, setting the categoryId field is preferred. If both fields are populated, the categoryId takes precedence, and the supplied name field is ignored, and populated based on the value of this field.

1 Expert replyverified_user

Re: Create location in v3 error - primary_category.CATEGORY_ID is required

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭
Just tried to use this category id from the spreadsheet and got this error:

.setPrimaryCategory(new Category().setCategoryId("software_company"));

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
"code" : 400,
"message" : "Request contains an invalid argument.",
"status" : "INVALID_ARGUMENT",
"details" : [ {
"@type" : "type.googleapis.com/google.mybusiness.v3.ValidationError",
"errorDetails" : [ {
"code" : 3,
"field" : "primary_category",
"message" : "This category isn't supported in US. Choose a supported category from the list that appears when you start entering a category.",
"value" : "software_company",
"additionalValue" : "US"
} ]
} ]
}

Re: Create location in v3 error - primary_category.CATEGORY_ID is required

[ Edited ]
Follower ✭ ✭ ☆
# 3
Follower ✭ ✭ ☆

I don't have the Java call, but the http call to set your category to Software company is https://mybusiness.googleapis.com/v3/accounts/ACCOUNTID/locations/LOCATIONID?languageCode=en&fieldMa... With your request body

{"primaryCategory": {
"name": "Software Company",
"categoryId": "gcid:software_company"
}
}

So I believe your categoryID needs to have gcid infront of it to work. Hope that helps

Re: Create location in v3 error - primary_category.CATEGORY_ID is required

[ Edited ]
Google Employee
# 4
Google Employee

Hi @Andrew S,

 

You can use the category list for a list of valid business categories when creating or updating a location. According to the Detailed Error Response you provided in your post with regard to the address of your location being in US and the languageCode query parameter of the POST request for creating a new location, the correct categoryId for the category name “Software Company” is “gcid:software_company”.

 

As of the launch of v3 of the Google My Business API, the categoryId field of a Category object must be specified for modifying a category when creating or updating a location.

 

Thanks,

Terry

Re: Create location in v3 error - primary_category.CATEGORY_ID is required

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Thanks gcid:software_company did work. Obviously it would be great if the code samples and documentation was updated to reflect the required changes.