Google Drive comments API showing unresolved comments when there are none - google-api

I have a Google Doc that I am testing the Comments API with. I've created, then deleted or resolved many comments. It currently shows no comments in the UI. However, when I search Comments.Get API on a specific Comment ID for the file, I am returned one that is both unresolved and not deleted. See API response below:
{
"kind": "drive#comment",
"commentId": "commentID",
"createdDate": "2020-10-21T12:29:27.941Z",
"modifiedDate": "2020-10-21T12:29:27.941Z",
"author": {
"kind": "drive#user",
"displayName": "My Name",
"picture": {
"url": "My Picture"
},
"isAuthenticatedUser": true
},
"htmlContent": "Comment",
"content": "Comment",
"deleted": false,
"status": "open",
"context": {
"type": "text/html",
"value": "some text in my file"
},
"anchor": "kix.bj5cxfssg70z",
"fileId": "FileID",
"fileTitle": "My File",
"replies": []
}
Does anyone know why this might be happening. It's not a propagation issue (I hope) because I made all these changes to doc over an hour ago and still this is what I receive

This can happen if you create a comment via API, especially if you do it for a file that does not support programmatic anchoring
So the comment is somewhere, you can see that it was created if you browse the Drive Activity (both prgramamtically and form the UI), but you cannot see the comment itself because it was wrongly anchored somewhere outside of the visible range of the document.
I assume it is related to this bug. Comment on it to see if it gets reopened, or "star" the feature request to increase visibility.

Related

Google Workspace Admin SDK insert member always set type to "USER", how to resolve this?

https://developers.google.com/admin-sdk/directory/reference/rest/v1/members
https://developers.google.com/admin-sdk/directory/reference/rest/v1/members (click for image)
It doesn't matter what I set "type" field to, in the request. It always sets it to "USER" in the response.
This is the request (click for image):
{
"email": "abcd#xyz.com",
"type": "EXTERNAL"
}
This is the response (click for image):
{
"kind": "admin#directory#member",
"etag": ""9zPsLeP9ycRovNIzMe3UcREkFqt8n_JNHD4izBpxyt4/BY6DTvfyl-lbLpaBG_gjKb9l_X0"",
"id": "110243826665778914981",
"email": "abcd#xyz.com",
"role": "MEMBER",
"type": "USER",
"status": "ACTIVE"
}
I tried to do the same, after unsuccessful attempts something I missed to notice in the documentation is the below:
EXTERNAL: The member is a user or group from outside the domain. (Not currently used)
Basically, it does not matter whether the user is external/internal its type will always be set to 'User'.

Is there a way to use variables within URLs of slack workflows actions?

I'm setting up a workflow that takes in a text variable I'd like to use in a later link.
For example, I ask for "Api Name", and then want to send a message that both references the api name as well as constructs a url (e.g. http://swagger.io/docs/"Api Name")
The problem I encounter is the links come up in plaintext if I just try to include that url as plaintext example as above. If I use the editor to try and add a link, the variable is not available.
My next thought was to try and edit the workflow json to supply some markdown in there, but it looks like the richtext is constructed from a series of elements.
A link looks like this:
{
"type": "link",
"url": "https://swagger.io/collections/",
"text": "(Link)"
},
And a token looks like this:
{
"type": "workflowtoken",
"id": "<some uuid>==user",
"property": "",
"data_type": "user",
"style": null
},
If I merely make the link plaintext and try to append the variable after the prefix I get something like this:
{
"type": "text",
"text": "https://swagger.io/thing/",
"style": {
"unlink": true
}
},
{
"type": "workflowtoken",
"id": "<uuid>==text",
"property": "",
"data_type": "text",
"style": null
},
So maybe if we knew all the values "type" could be that would help?
Not sure where to go from here. Anyone have any suggestions?
Here is an answer from Slack Support Service:
We don't yet support Workflow variables outputted in links, I'm
afraid.
This is feedback we hear quite a bit so hopefully it's the something
the team will consider implementing in the future.

POST google Places API - INVALID_REQUEST

{
"location": {
"lat": -33.8669710,
"lng": 151.1958750
},
"accuracy": 50,
"name": "Google Shoes!",
"phone_number": "(02) 9374 4000",
"address": "48 Pirrama Road, Pyrmont, NSW 2009, Australia",
"types": ["shoe_store"],
"website": "http://www.google.com.au/",
"language": "en-AU"
}
This one I tried and as well as other places without modifying the request structure with Indian places. I'm getting the following response:
{
"html_attributions": [],
"results": [],
"status": "INVALID_REQUEST"
}
I'm not getting exactly what is the Issue, please revert back for the solution.
Since you didn't specify, I'm assuming that you are trying to use the add places endpoint on the Places API described here in the documentation.
The most likely problem is that you neglected to include your API key in the request URL, which should look like this:
https://maps.googleapis.com/maps/api/place/add/json?key=YOUR_API_KEY
Note that this endpoint is deprecated and that Google may remove it altogether at some point in the future.

How to get the url of the reference attachment?

I am using Microsoft Graph. When I use
GET /me/messages/{messageId}/attachments
If there is an attachment shared through OneDrive or SharePoint, the #odata.type will be #microsoft.graph.referenceAttachment. And the size is very small because it is not real file.
{
"#odata.type": "#microsoft.graph.referenceAttachment",
"id": "AAMkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA1ODZlMDI5MgBGAAAAAACUbnk-iwQZRbXMgkfKtmYhBwCpTc-InBsuTYwTUBb_VIb4AAAAAAEMAACpTc-InBsuTYwTUBb_VIb4AAEBiQutAAABEgAQAMqgyfrokPFCrRfUa2mrxxM=",
"name": "word.docx",
"contentType": null,
"size": 4601,
"isInline": false
}
Is there any way to get the actual url of this attachment that can be opened in the browser? Thanks
The v1.0 edition has very limited support for referenceAttachment. And by that I mean, there isn't much you can do with them beyond acknowledging one exists.
The beta edition however supports a much richer referenceAttachment object. When I come across a referenceAttachment, I make the call to retrieve the attachment using the beta endpoint which does have links to the actual file:
{
"contentType": "string",
"id": "string (identifier)",
"isFolder": true,
"isInline": true,
"lastModifiedDateTime": "String (timestamp)",
"name": "string",
"permission": "string",
"previewUrl": "string",
"providerType": "string",
"size": 1024,
"sourceUrl": "string",
"thumbnailUrl": "string"
}
What you are after is sourceUrl property of referenceAttachment resource:
URL to get the attachment content. If this is a URL to a folder, then
for the folder to be displayed correctly in Outlook or Outlook on the
web, set isFolder to true. Required.
but this property is not available for v1.0 API version, beta endpoint needs to be utilized instead:
https://graph.microsoft.com/beta/me/messages/{message-id}/attachments/{arrachement-id}

How to know it is auto reply mail in Microsoft Graph?

I am using Microsoft Graph API to get mails.
GET /v1.0/me/messages
It returns
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('576552d5-3bc0-42a6-a23d-bfceb405db23')/messages",
"#odata.nextLink": "https://graph.microsoft.com/v1.0/me/messages?$skip=11",
"value": [
{
"#odata.etag": "W/\"HwAAABYAAACpTc/InBsuTYwTUBb+VIb4AACqi2tx\"",
"id": "AAMkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA1ODZlMDI2MgBGAAAAAACUbnk-iwQZRbXMgkfKtmYhBwCpTc-InBsuTYwTUBb_VIb4AAAAAAEMAACpTc-InBsuTYwTUBb_VIb4AACqNTk9AAA=",
"createdDateTime": "2017-12-06T21:57:09Z",
"lastModifiedDateTime": "2017-12-06T21:57:19Z",
"changeKey": "HwAAABYAAACpTc/InBsuTYwTUBb+VIb4AACqi8tx",
"categories": [],
"receivedDateTime": "2017-12-06T21:57:09Z",
"sentDateTime": "2017-12-06T21:56:16Z",
"hasAttachments": false,
"internetMessageId": "<e74a536a53d245e49d779d47f774f4a0#CO2PR00MB0214.namprd00.prod.outlook.com>",
"subject": "Automatic reply: Hi",
"bodyPreview": "I am OOF.",
"importance": "normal",
"parentFolderId": "AAMkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA2ODZlMDI5MgAuAAAAAACUbnk-iwQZRbXMgkfKtmYhAQCpTc-InBsuTYwTUBb_VIb4AAAAAAEMAAA=",
"conversationId": "AAQkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA2ODZlMDI5MgAQAPekscpearpHmBFbhG0DKuc=",
"isDeliveryReceiptRequested": null,
"isReadReceiptRequested": false,
"isRead": true,
"isDraft": false,
"webLink": "https://outlook.office365.com/owa/?ItemID=AAMkADBlZTUwNTkxLWVmODgtNDVhNC1iZjhlLTdjNjA1ODZlMDI5MgBGAAAAAACUbnk%2FiwQZRbXMgkfKtmYhBwCpTc%2FInBsuTYwTUBb%2BVIb4AAAAAAEMAACpTc%2FInBsuTYwTUBb%2BVIb4AACqNTk2AAA%3D&exvsurl=2&viewmodel=ReadMessageItem",
"inferenceClassification": "focused",
"body": {
"contentType": "html",
"content": "hi"
},
"sender": {
"emailAddress": {
"name": "Jack",
"address": "jack#example.com"
}
},
"from": {
"emailAddress": {
"name": "Jack",
"address": "jack#example.com"
}
},
"toRecipients": [
{
"emailAddress": {
"name": "Rose",
"address": "rose#example.com"
}
}
],
"ccRecipients": [],
"bccRecipients": [],
"replyTo": []
}
]
}
I didn't find any field related with determine whether it is an auto reply mail.
Right now I am using
mail.subject.startsWith('Automatic reply:')
to determine whether is auto reply mail in code.
However, it is not reliable. Because sometimes I got mails starting with a different language such as Resposta automática:.
So how to know it is auto reply mail correctly?
As #Horkrine said there is no officially guaranteed way of detecting if an email is an auto reply or not.
But there are two ways that may be useful:
Method 1 : Detect the response time
If you are capable, consider checking the amount of time between the email sent and the response. If that time is within a certain threshold, it is almost certainly an auto reply. Consider a reply received within seconds, for example. This has a lot of correlations with modern-day spam-robot detection techniques.
Method 2 : Keywords
The other way to do it is to look for keywords, just as you are doing now. However, you also have to account for other languages, variations on spelling, misspellings, etc. You will not get everything.
For example:
mail.subject.contains('Automatic') OR mail.subject.contains('Auto-matic') OR mail.subject.contains('Away') OR mail.subject.contains('out of office')
...
OR mail.subject.contains('automática') ...
Rather than typing out such a list, I would recommend doing a quick search on the internet and see if there are any such lists you can copy-paste from, as surely someone has done this sort of thing before and has some free code.
I'm no expert but I don't believe there's any way to determine whether or not an email is an automatic reply unless the email actually contains a string saying "This is an automatic reply" or something.
Just found another interesting API getMailTips, however this can only help determine the auto mail if the other user is Outlook or Office 365 user.
Copy the demo below for convenience.
POST https://graph.microsoft.com/api/beta/users/{id|userPrincipalName}/getMailTips
{
"EmailAddresses": [
"danas#contoso.onmicrosoft.com",
"fannyd#contoso.onmicrosoft.com"
],
"MailTipsOptions": "automaticReplies, mailboxFullStatus"
}
It will return something like
{
"#odata.context":"https://graph.microsoft.com/api/beta/$metadata#Collection(microsoft.graph.mailTips)",
"value":[
{
"emailAddress":{
"name":"",
"address":"danas#contoso.onmicrosoft.com"
},
"automaticReplies":{
"message":"<style type=\"text/css\" style=\"\">\r\n<!--\r\np\r\n\t{margin-top:0;\r\n\tmargin-bottom:0}\r\n-->\r\n</style>\r\n<div dir=\"ltr\">\r\n<div id=\"x_divtagdefaultwrapper\" style=\"font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif\">\r\n<p>Hi, I am on vacation right now. I'll get back to you after I return.<br>\r\n</p>\r\n</div>\r\n</div>",
"messageLanguage":{
"locale":"en-US",
"displayName":"English (United States)"
}
},
"mailboxFull":false
},
{
"emailAddress":{
"name":"",
"address":"fannyd#contoso.onmicrosoft.com"
},
"automaticReplies":{
"message":""
},
"mailboxFull":false
}
]
}

Resources