Microsoft Graph API - Search email using application permission - microsoft-graph-api

I want to search email using Graph API in my own developed application. By referring to these threads - Graph Api: Region is required when request with application permission , How to use Graph API Sharepoint Search from console app , Search content with application permissions , I tried to run the search which resulted in Application permission is only supported for the following entity types:site, list, listItem, drive and driveItem. (Request and response json is below).
Does it mean that using an app like a console application developed in C# will not be able to search the emails (as message is not mentioned in error response - only these are mentioned: site, list, listItem, drive and driveItem) even if it has required secret, auth token and permissions?
Request:
URL : https://graph.microsoft.com/beta/search/query
Request Payload:
{
"requests": [
{
"entityTypes": [
"person"
],
"query": {
"queryString": "contoso"
},
"Region" : "NAM",
"from": 0,
"size": 25
}
]
}
Response:
{
"error": {
"code": "System.UnauthorizedAccessException",
"message": "Application permission is only supported for the following entity types:site, list, listItem, drive and driveItem.",
"target": "",
"httpCode": 403
},
"Instrumentation": {
"TraceId": "7174e417-a2fe-02e5-1523-1fcda7a66886"
}
}

Related

Search mails using graph api

we are using microsoft graph api list and send emails. The new requirement is to search emails. When following URL is tried then we are getting errors. Can someone suggest if this is the right api to search mails messages? or what kind of permissions are missing?
URL : https://graph.microsoft.com/v1.0/search/query (documentation here)
Error using following request body : "Application permission is only supported for the following entity types:site, list, listItem, drive and driveItem."
{
"requests": [
{
"entityTypes": [
"message"
],
"query": {
"queryString": "hello"
},
"region": "NAM",
"from": 0,
"size": 25
}
]
}
Error returned::
"code": "System.UnauthorizedAccessException",
"message": "Application permission is only supported for the following entity types:site, list, listItem, drive and driveItem.",
"target": "",
"httpCode": 403
When tried to change the body to get list, as expected it did not return list, as we have only mail.readwrite permissions.
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "contoso"
},
"region": "NAM",
"sharePointOneDriveOptions": {
"includeContent": "privateContent,sharedContent"
}
}
]
}
Error Returned:
"code": "System.UnauthorizedAccessException",
"message": "Access to ListItem in Graph API requires the following permissions: Sites.Read.All or Sites.ReadWrite.All. However, the application only has the following permissions granted: Mail.ReadWrite, Mail.Read",
"target": "",
"httpCode": 403
As per the doc - Known limitation , You can access only the signed-in user’s own mailbox. Searching delegated mailboxes is not supported. try to write query to search your own message.
Hope this helps
Thanks

Google My Business API - How to extract logo and cover with new API version

I have to retrieve the logo and cover from the Google My Business Locations and I would like to understand which kind of API I should call.
To get the locations list I've called the accounts.locations.list and the REST services give me back the correct results with a lot of data.
But these results do not contain the media logo and cover, and reading the documentation I've seen this page accounts.locations.media.list but it refers to the old API with a hostname "mybusiness.googleapis.com" while the other is "mybusinessbusinessinformation.googleapis.com", and calling it with the OAuth 2.0 Playground the service returns this error:
{
"error": {
"status": "PERMISSION_DENIED",
"message": "Google My Business API has not been used in project 711831863231 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/mybusiness.googleapis.com/overview?project=711831863231 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"code": 403,
"details": [
{
"#type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"url": "https://console.developers.google.com/apis/api/mybusiness.googleapis.com/overview?project=711831863231",
"description": "Google developers console API activation"
}
]
},
{
"reason": "SERVICE_DISABLED",
"#type": "type.googleapis.com/google.rpc.ErrorInfo",
"domain": "googleapis.com",
"metadata": {
"consumer": "projects/711831863231",
"service": "mybusiness.googleapis.com"
}
}
]
}
}
so I thought that I needed to add the API on the Google Console page but all the My Business API are enabled and I don't see a generic My Business or a specific Media API to add.
I think this API might be disable as showed on the response with the label "SERVICE_DISABLED" but I can't understand which API I have to call to extract this information (logo and cover, but also the other media linked with the location).

I can't get this Google Sheets API Get request to work

I am trying to have a game to request data from the Google Sheets API, and I can't get the API Key to function properly. I can visit my API Link in the browser, and it tells me it is getting HTTP 400 (Bad Request) and Google additionally says it's a bad API Key, despite having JUST generated it. For reference my link looks like this: "https://sheets.googleapis.com/v4/spreadsheets/[SHEET_ID]?key=[API_KEY]/values", and the browser views this when using it:
"error": {
"code": 400,
"message": "API key not valid. Please pass a valid API key.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "API_KEY_INVALID",
"domain": "googleapis.com",
"metadata": {
"service": "sheets.googleapis.com"
}
}
]
}
}
I have absolutely no idea what is going wrong, I know the API key and Sheet ID are right (Directly copied each from their respective source).

Microsoft Graph API - Invite endpoint returning Bad request every time

I'm trying to share SharePoint directory so specific user invite the invite API endpoint from Microsoft Graph : https://learn.microsoft.com/en-us/graph/api/driveitem-invite
Every time I do the request, I'm receiving a "400 - Bad request" response.
Here is my request:
https://graph.microsoft.com/v1.0/sites/***/drives/***/items/***/invite
Here is the payload:
{
"requireSignIn": true,
"sendInvitation": false,
"roles": [
"read"
],
"recipients": [
{
"email": "***#***.***"
}
]
}
It used to work perfectly.

Google+ Domains API Not Configured

When I try to post an activity to Google+ I get the error:
{
"error": {
"code": 403,
"message": "Access Not Configured. The API (Google+ Domains API) is not enabled for your project. Please use the Google Developers Console to update your configuration.",
"errors": [
{
"domain": "usageLimits",
"message": "Access Not Configured. The API (Google+ Domains API) is not enabled for your project. Please use the Google Developers Console to update your configuration.",
"reason": "accessNotConfigured",
"extendedHelp": "https://console.developers.google.com"
}
]
}
}
I know this question has been asked before here, but I have a different message in my error. I've also enabled Google Domains API in the console. I'm using a Gmail account and I also receive circles and contacts information with the following scopes:
https://www.googleapis.com/auth/userinfo.email
https://www.google.com/m8/feeds https://www.googleapis.com/auth/plus.login
https://www.googleapis.com/auth/plus.stream.write
https://www.googleapis.com/auth/plus.me
My Post body is:
{
"object": {
"originalContent": "Happy Monday! #caseofthemondays"
},
"access": {
"items": [
{
"type": "domain"
}
],
"domainRestricted": true
}
}
Found out this feature is only available for Google Apps customers not anyone else.
Reference
Have you created (or using) the API_KEYs in your Google project?
If not, go to Google developer console and select the credentials section under APIs & Auth and create the API key relevant for your application.
If you already have a key, try regenerating a new one

Resources