People API getting error when Age Ranges is specified - google-apps-script

I have tried with People contact create API but I am getting error. I believe the ENUM data is correct
This happens for Skills and Age ranges
{
"error": {
"code": 400,
"message": "person.age_ranges is a read only field.",
"status": "INVALID_ARGUMENT"
}
}
People.People.createContact( {"skills": [
{
"value": "Playing"
}
],
"ageRanges": [
{
"ageRange": "TWENTY_ONE_OR_OLDER"
}
],
})

Answer:
The ageRanges[] field can not be set as it is a read-only field.
More Information:
As per the Person resource in the documentation:
ageRanges[]
object (AgeRangeType)
Output only. The person's age ranges
As this is an output only value, it can not be written to by calling people.createContact.

Related

Get all fields from google spreadsheet with api v4

I'm setting up a project in NodeJS and for testing I get the information from a spreadsheet in JSON format from the following page: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchGet
To obtain the information of a sheet, in the spreadsheetId field I put the ID of the spreadsheet and in the range field the name of the sheet.
This is the JSON I get:
{
"spreadsheetId": "{spreadsheetId}",
"valueRanges": [
{
"range": "Parameters!A1:Z1000",
"majorDimension": "ROWS",
"values": [
[
"Country",
"COLOMBIA"
]
]
}
]
}
What I want is to show all the fields of the sheet to obtain the title and the modification and creation dates. To do this, in the fields field, I am putting the title string but I get the following error:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "title",
"description": "Error expanding 'fields' parameter. Cannot find matching fields for path 'title'."
}
]
}
]
}
}
I have tried putting * but I get the same JSON.
My problem: How can I get the date of creation and the date of last modification of the spreadsheet?
you must use this endpoint to get a spreadsheet properties: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get

Getting 400 error ( invalid argument - latlng )while updating the location details via Google my business API

I've a business published in Google My business.It is in live. I tried to update the location details via API. But I'm getting 400 error and getting the following response.
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.mybusiness.v4.ValidationError",
"errorDetails": [
{
"code": 3,
"field": "latlng",
"message": "The specified address cannot be located. Please use the UI to provide a pin drop."
}
]
}
]
}
}
But in the above scenario, patch request doesn't contains the location coordinates. But I still getting the specified address cannot be located response.
Body of patch request::
{
"primaryPhone": "xxxxxxxxx",
"locationName": "xxxx",
"address": {
"regionCode": "IN",
"postalCode": "xxxxx",
"locality": "xxxxx",
"addressLines": [
"xxxxxx xxxx xxxx"
],
"administrativeArea": "xxxx xxxxxx"
},
"primaryCategory": {
"displayName": "Apartment building",
"categoryId": "gcid:apartment_building"
},
"languageCode": "en",
"storeCode": "xxxxxx9dda0dc5-c709-410c-a272-912486b1b5f4"
}
This is doesn't contains the lat,lng but still getting the same lat,lng field error.
Actually I've changed the name only change . I don't know how it is related to lat,lng.
And tried updating without the address field and with address field. But in both case getting the same response.
Seems like you are using this method (https://developers.google.com/my-business/reference/rest/v4/accounts.locations/patch).
This error occurs when Google determines that their own Geocoder doesn't really know where they should be placing the pin for that address. So additionally to the address property, Google may(!) allow you to also send them the latLng property - if Google determines that this is a credible set of coordinates, the address will be updated.
It is however still possible that they won't believe you that you know where that address is exactly. In that case, the only way to get address data through is in fact to go to the Google My Business UI of the location and manually dragging that pin to where it needs to go.

How to handle dynamic json in flutter?

{
"status": "error",
"msg": "Please fill all the fields",
"error": {
"device_token": [
"The device token field is required.",
]
"mobile_number": [
"The mobile number field is required."
]
}
}
Here is my json response .How can i handle my error as the error object is dynamic
Keep your JSON content in a variable and access your data as following.
Also, don't forget the comma "," after the "device_token" key
var res = {
"status": "error",
"msg": "Please fill all the fields",
"error": {
"device_token": [
"The device token field is required."
],
"mobile_number": [
"The mobile number field is required."
]
}
};
var deviceToken = (res["error"] as Map)["device_token"].first;
var mobileNumber = (res["error"] as Map)["mobile_number"].first;
print(deviceToken);
print(mobileNumber);
I'd recommend reading JSON and Serialization in the Flutter docs.
I use json_seializable. It is a good way to solve this problem.
Just to mark your models with decorators and generate each method automatically. BTW, this is recommended on flutter documentation.
And also it is really important to add types to your variables and use the Dart compiler's power

Why can't I submit a record to Zoho Sales Order API?

I'm trying to insert a record using the Zoho API, and I keep receiving a cryptic INVALID_DATA error message.
I've tried using their sample code which, of course, produces another error. And the sample code they provide for running in Postman also produces an error.
Their docs are lacking and inconsistent, and nobody is getting back to me on their message boards, and I'm getting desperate as I need to have this done today. Can anyone see what I'm doing wrong?
This is what I'm submitting via Postman
{
"data": [
{
"Owner": {
"id": "3938209039489388001"
},
"Contact_Name": {
"id": "398129039938498309"
},
"Subject": "Test",
"Product_Details": [
{
"product": {
"id": "1234567"
},
"quantity": 1
}
]
}
]
}
This is the error response
{
"data": [
{
"code": "INVALID_DATA",
"details": {
"api_name": "product",
"index": 0,
"parent_api_name": "Product_Details"
},
"message": "invalid data",
"status": "error"
}
]
}
The solution was to POST a product first, then grab that product ID and insert it under Product_Details. This is not documented, so I assumed the product would be created automatically, which it wasn't.

Google fit API add multiple data type based on scope

I am using google fit API with multiple user scopes. How can I add multiple data type for each source. If possible, why I cannot add this as a datasource.
{
"dataStreamName":"MyDataSource",
"type":"derived",
"application":{
"detailsUrl":"http://example.com",
"name":"Foo Example App",
"version":"1"
},
"dataType":[
{
//1st data type
"name":"com.google.step_count.delta",
"field":[
{
"name":"steps",
"format":"int"
}
]
},
{
//2nd data type
"name":"com.google.calories.bmr",
"field":[
{
"name":"calories",
"format":"float"
}
]
}
],
"device":{
"manufacturer":"Example Manufacturer",
"model":"ExampleTablet",
"type":"tablet",
"uid":"1000001",
"version":"1.0"
}
}
And I got a response of
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"dataType\" at 'data_source': Proto field is not repeating, cannot start list.",
"errors": [
{
"message": "Invalid JSON payload received. Unknown name \"dataType\" at 'data_source': Proto field is not repeating, cannot start list.",
"reason": "invalid"
}
],
"status": "INVALID_ARGUMENT"
}
}
But when I only add one scope which is like this
{
"dataStreamName":"MyDataSource",
"type":"derived",
"application":{
"detailsUrl":"http://example.com",
"name":"Foo Example App",
"version":"1"
},
"dataType":{
"name":"com.google.step_count.delta",
"field":[
{
"name":"steps",
"format":"integer"
}
]
},
"device":{
"manufacturer":"Example Manufacturer",
"model":"ExampleTablet",
"type":"tablet",
"uid":"1000001",
"version":"1.0"
}
}
It returns me 200 which is successful. Did I miss something or is what I am trying to do possible? Thanks.
Google fit API reference
https://developers.google.com/fit/rest/v1/reference/users/dataSources/create
I believe the nesting your trying to do has to go at the dataField level rather than the dataType level.
dataType.field[]
I think this because I noticed that 'field[]' is a collection while dataType is not.