Non-existent param "Fingerprint" in google contactsGroup api - google-contacts-api

I'm trying to update the label in google contacts using the method from the docs
https://developers.google.com/people/api/rest/v1/contactGroups/update
Got a response
{
"error": {
"code": 400,
"message": "Fingerprint is missing.",
"status": "INVALID_ARGUMENT"
}
}
Even though Google API Explorer
How solve this, maybe someone can help. What does this Fingerprint mean? I can create/delete label but not update!

You have to include the etag.
If you go to Method: contactGroups.get or the Method: contactGroups.list, on the response you will find the groups 'etag'
Then on the Method: contactGroups.update request body you set the new name you want the group to have and also include the etag like this:
{
"contactGroup": {
"name": "newOne2",
"etag": "r*****k="
}
}

Related

PUT method doesn't work on Wordpress REST API

let me explain my problem
In my wordpress site I installed the WP REST API plugin to be able to read some listing fields via API
With postman if I use
GET https://mysitecom/wp-json/wp/v2/job-listings/1010
I get the following json correctly:
{
"id": 10565,
...
"status": "publish",
"type": "job_listing",
"title": "first try",
...
"_company_whatsapp": "",
"_company_mobile": "3331234567",
"_company_website": "",
"_company_use_social_networks": "",
"_company_facebook": "",
"_company_instagram": "",
...
}
If I want to edit 2 fields and use
PUT https://mysitecom/wp-json/wp/v2/job-listings/1010
with the following json:
{
"title": "edit try",
"_company_mobile": "3339999999",
}
It change the title but not the phone number.
If I try to change only the number with
{
"_company_mobile": "3339999999",
}
Postman returns this to me
{
"code": "rest_invalid_json",
"message": "JSON with invalid body was passed.",
"data": {
"status": 400,
"json_error_code": 4,
"json_error_message": "Syntax error"
}
}
I'm approaching the use of APi for the first time, what am I doing wrong? What is the problem and how can I fix it?
Thanks in advance
This json is invalid:
{
"_company_mobile": "3339999999",
}
You should remove the comma:
{
"_company_mobile": "3339999999"
}
Normally this is expected behaviour for PUT. You can skip fields only if they are optional. You cant pass only the field you want to update. Think of PUT like overwrite. The api applies the same validation like it will do for create (POST). Some APIs provide partial update with PATCH verb. Then you can provide only the fields you want to update usually as query params. Not sure what is exactly the case with Wordpress api.

MS Graph batching create list item (SPO) Invalid batch payload format

I did see this same error, in c# has an open question, but I'm using PowerShell and using POST rather than PATCH so I've opened a separate question.
I'm having an issue when using JSON batching, particularly that when I include the header for Content-Type, I receive:
Invoke-RestMethod : {
"error": {
"code": "BadRequest",
"message": "Invalid batch payload format.",
"innerError": {
"date": "2020-10-14T00:25:46",
"request-id": "aa535dbb-efe8-450e-911d-143554ed9027",
"client-request-id": "aa535dbb-efe8-450e-911d-143554ed9027"
}
}
}
I first had missed including the headers at all, and was receiving the error:
{
"error": {
"code": "BadRequest",
"message": "Write request id : 2 does not contain Content-Type header or body.",
"innerError": {
"date": "2020-10-14T00:46:58",
"request-id": "3601be6d-a861-4947-936b-451cd9de80c3",
"client-request-id": "3601be6d-a861-4947-936b-451cd9de80c3"
}
}
}
The body of my HTTP request to https://graph.microsoft.com/v1.0/$batch is an array of PSCustomObjects that look like this:
id : 1
method : POST
url : sites/8c3cb1ef-4116-b0e4-6d0b-25d0f333a4ed/lists/a2b2d34e-6d32-df22-d562-472d3d8385d2/items
body : {
"fields": {
"DisplayName": "user1#contoso.com",
"CreatedDateTime": "2019-10-13",
"UserId": "c963d785-59fc-4384-5e7d-d466=2118e3347",
"UserType": "Guest",
}
}
headers : {
"Content-Type": "application/json"
}
I found it odd that when I omit headers, the payload is seemingly OK, and it sees that Content-Type has not been supplied. Once I add it in, then suddenly payload is not OK.
If I individually perform the requests, all the same data, it's also fine (items create in SPO list without issue). I feel like this fact confirms that the issue is not with the fields in the body.
I have no issues when batching GET requests (e.g. batching 100's of requests for auditLogs/signIns). These are essentially the same payload, minus no body/headers, so just id, url, and method.
Has anyone had any experienced this and found a solution?
PS. The Guid's are all fakes.
My issue ended up being that I needed to use ConvertTo-Json's -Depth parameter to successfully capture all of my body's content. It was 5 levels deep (Requests: [ Each Request: { body: { fields: { field names/values } } } ]).
This was only an issue with POST method requests, since a body is then needed, which in this case was for adding SPO list items, which requires the fields: key with children names and values for the list's columns / cells.

OAuth consent screen - ability to remove application logo: old solution is no longer working

Question: how to remove an application logo.
Solution: previous solution from this answer, https://stackoverflow.com/a/57168008/1992004, is no longer working.
Google changed the format of "iconUrl" to "icon", and uses now the Base64-encoded data stream, like "icon":"iVBORw0KGgoAAAAN..., instead of the image URL, previously written as "iconUrl":"https://...".
I've tried "icon":"" and many Base64-encoded values like "icon":"IA", "icon":"Lw", and some of other - no success. I get console messages like
for "icon":""
{
"error": {
"code": 400,
"message": "The request failed because one of the field of the resource is invalid.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.PreconditionFailure",
"violations": [
{
"type": "client_auth_config",
"subject": "?error_code=9&error_field_name=UpdateIconRequest.icon&error_field_value=%3CByteString#3eeee81e+size%3D0+contents%3D%22%22%3E"
}
]
}
]
}
}
or
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.identity.clientauthconfig.v1.ClientAuthConfigError",
"code": "ICON_STORAGE_FAILURE"
},
{
"#type": "type.googleapis.com/google.identity.clientauthconfig.v1.IconStorageError",
"reason": "INVALID_IMAGE"
}
]
}
}
or
{
"error": {
"code": 400,
"message": "Invalid value at 'icon' (TYPE_BYTES), Base64 decoding failed for \" \"",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "icon",
"description": "Invalid value at 'icon' (TYPE_BYTES), Base64 decoding failed for \" \""
}
]
}
]
}
}
Does somebody know, what should be inserted here to remove the logo image from the app?
Answer:
Unfortunately, there is no way for this to be done.
More Information:
Once an OAuth Application Logo has been uploaded there isn't a supported way of removing it - in the question that you linked the way that this was done is a bit hacky, inspecting the network requests and building a new request from the previous JSON object sent via the UI really shows this.
As the icon URL has changed to need a Base-64 encoded value this has been deprecated. Whether this was intentional by Google or not is hard to say, but now an empty value will always return INVALID_ARGUMENT. Any data in the value for icon will also just replace the image data and so this isn't a viable workaround, as as far as the validation process goes, image data exists and so will need to be verified.
If it's not too much of a arduous process, the only workaround here is to create a new GCP project with a new OAuth consent screen without uploading an image. Of course, you will need to reactivate all the relevant APIs and link the relevant scripts and projects to the new set-up.
Feature Request:
You can however let Google know that this is a feature that is important and that you would like to request they implement it. Google's Issue Tracker is a place for developers to report issues and make feature requests for their development services. I would suggest using the feature request template for G Suite Add-ons as this is a component for which GCP Projects could be used.
Update: The feature request for this is viewable here, to increase visibility on this, hit the ☆ at the top of the page.
Relevant Questions:
OAuth consent screen - ability to remove application logo [Obsolete]
May 2021 - It is still possible to completely delete the consent screen (and thus allowing to create it again). See my updated answer in https://stackoverflow.com/a/57168008/1992004

How to read the projectId from webhook callback?

The POST /webhooks/v1/systems/data/hooks works fine, the events are created as expected, but the callback is missing the project_id for A360 that I need to access the file.
How to include that on the callback payload?
You can use the hookAttribute property on the POST body and include custom information, such as the projectId or any other information from your app. Here is an example:
{
"callbackUrl": "http://abcd1234.ngrok.io/forge/callback",
"scope": {
"folder": "urn:adsk.wipprod:fs.folder:co.abcd1234"
},
"hookAttribute": {
"projectId": "a.1234.abcd.5678.defg"
}
}

Google Search Console 401 Bad Request issue without using Client Library

So, Here are 3 steps.
I called oAuth2 with following url:
https://accounts.google.com/o/oauth2/v2/auth
?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fwebmasters%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fwebmasters.readonly
&client_id=___.apps.googleusercontent.com
&redirect_uri=urn:ietf:wg:oauth:2.0:oob
&response_type=code
&approval_prompt=force
&access_type=offline
I get the code, suppose: 4/QVgPaCMqp94____qBC4NY_d54IcRj7U9mJc
Then I'm making a request for access_token, by making a POST request to https://accounts.google.com/o/oauth2/token with client_id, client_secret, redirect_uri, grant_type, and I get a JSON like:
'access_token' => ya29.CjHzAgC4js6Guv-1pt_rE____q8XIxiXOXOaSZW9NLRjKCTI3izBi,
'expires_in' => 3600,
'refresh_token' => 1/dL3ENA-EVI0rEb6D-OGqw_____iFe2ZNdEq4,
Now, I am making a request with that access_token or in cases of expiry with a renewed access_token to Google Search Console, which I have added in scopes.
My request is similar to this: https://developers.google.com/webmaster-tools/v3/urlcrawlerrorssamples/list#try-it
But I get an 401 unauthorized error, with a json like following:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
Considering I have done the process correctly, I think I have missing some parameters or providing some wrong value.
I have not used Google Client Library, instead used the REST API framework directly.
Can anybody give some clue please? Thank you.
The reason is, URL query parameter must be ?access_token= and not ?key= The later can be used only in case of direct API access and not oAuth.