Cannot send email using Microsoft Graph explorer - microsoft-graph-api

This is the new error message that I am encountering now. When trying out graph explorer (https://developer.microsoft.com/en-us/graph/graph-explorer) to execute office 365 APIs using my company account, I am encountering an error below when using APIs for Outlook Mail and Calendar. Same error encountered for the applications that I have downloaded in Github. Applications that are trying to access the calendar APIs. I have also tried to create a developer account for office 365 and it has the same error message when accessing the APIs.
It looks like an access issue and/or admin privilege is needed.
Error response:
{
"error": {
"code": "ResourceNotFound",
"message": "Resource could not be discovered.",
"innerError": {
"request-id": "351f57d5-3bdb-4c6f-a06c-b204f23d0eda",
"date": "2018-06-13T03:12:28"
}
}
}
But I can access User APIs. Like getting my profile details in OSM AD.
Successful response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"id": "987f2dcf-a66c-4f14-a180-41e2eac0b65c",
"businessPhones": [
"+47 37 50 46 15"
],
"displayName": "Teemee F Tang",
"givenName": "Teemee F",
"jobTitle": null,
"mail": "Teemee.Tang#osm.no",
"mobilePhone": "+63 947 33 71109",
"officeLocation": null,
"preferredLanguage": null,
"surname": "Tang",
"userPrincipalName": "Teemee.Tang#osm.no"
}

I just login my account in https://outlook.office365.com. After that I can already use my company account with Microsoft Graph.

Related

Accessing Intune Graph API Forbidden Error

I am O Auth 2 authorization code flow to Authenticate to Azure and Invoke Graph APIs for Intune (by delegated app that was created in Intune for access to API).
Following permissions has been provided at the APP registered in Azure under my organization tenant.
https://graph.microsoft.com/DeviceManagementApps.Read.All https://graph.microsoft.com/DeviceManagementConfiguration.Read.All https://graph.microsoft.com/DeviceManagementManagedDevices.Read.All https://graph.microsoft.com/User.Read
API under scope:
https://graph.microsoft.com/v1.0/deviceManagement/detectedApps
https://graph.microsoft.com/v1.0/deviceAppManagement/mobileApps```
I am getting the following error both at Mobile APP level and Postman. Could you please help me to identify the issue?
{
"error": {
"code": "UnknownError",
"message": {
"ErrorCode": "Forbidden",
"Message": {
"_version ": 3,
"Message": "An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: c85eb7ab-687d-4780-bd88-94a3b52e7df7 - Url: https://fef.msub02.manage.microsoft.com/DeviceConfiguration_2008/StatelessDeviceConfigurationFEService/deviceManagement/deviceConfigurations?api-version=2020-02-21",
"CustomApiErrorPhrase": "",
"RetryAfter": null,
"ErrorSourceService": "",
"HttpHeaders": {
"WWW-Authenticate": "Bearer realm=urn:intune:service,bb7003b9-cb7f-44b2-b534-54f84f2f0d63,f0f3c450-59bf-4f0d-b1b2-0ef84ddfe3c7"
}
},
"Target": null,
"Details": null,
"InnerError": null,
"InstanceAnnotations": []
},
"innerError": {
"date": "2020-09-02T21:09:14"
"request-id": "c85eb7ab-687d-4780-bd88-94a3b52e7df7",
}
}```
You can try using the Global Administrator role or a Global reader role to read the intune data as there is a necessity of having these roles. After giving any of these roles, try the below calls with their respective permissions.
https://graph.microsoft.com/v1.0/deviceManagement/detectedApps
https://graph.microsoft.com/v1.0/deviceAppManagement/mobileApps

Is there a way to prevent the 404 error for consumer accounts when attempting to fetch non-consumer data?

I have an application that fetches profile data using Microsoft Graph APIs. The application should be able to fetch profiles for both Work/School Azure account and consumer Azure accounts. The issue I have is that when I am retrieving data that is exposed on Work/School accounts but not a consumer accounts, I get a 404 error. In other words, my application should handle Work/School accounts and consumer accounts the same, only fetching data that is exposed by Microsoft Graph for a consumer account without returning an error when data is unexposed.
Calling this endpoint https://graph.microsoft.com/v1.0/me/ with authorization token for a consumer account, I get the following response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(etc)/$entity",
"displayName": "<fullname>",
"surname": "<lastname>",
"givenName": "<firstname>",
"id": "value",
"userPrincipalName": "value#hotmail.com",
"businessPhones": [],
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null
}
Calling https://graph.microsoft.com/v1.0/me/?$select=birthday with a Work/School account, I get data I can work with. Meanwhile calling https://graph.microsoft.com/v1.0/me/?$select=birthday with the same authorization token returns:
{
"error": {
"code": "ResourceNotFound",
"message": "Resource not found.",
"innerError": {
"request-id": "5dac0b98-0335-4de2-b8fa-3b9a2dfbe378",
"date": "2019-04-26T23:23:21"
}
}
}
Is there any way to retrieve the profile data for a consumer account while still attempting to retrieve the unexposed data in a Work/School account without getting a 404 returned?
Since you are requesting data that doesn't exist (birthday), you should be getting a 404 Not Found response. Per RFC 7231 Section 6.5.4 :
The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Creating direct HTTP-request through YouTube Analytics API v2 to view the videos of the channel that were embedded on external sites

I am quite new in using Google APIs. So, the problem is that I am administrator of the YouTube channel (not the owner). And I would like to get the straffic sources that were embedded on external websites. So, I've created new project and formed a request through Google APIs Explorer. Here it is:
https://youtubeanalytics.googleapis.com/v2/reports?dimensions=insightTrafficSourceDetail&endDate=2018-12-12&filters=insightTrafficSourceType%3D%3DEXT_URL&ids=channel%3D%3D{MY_CHANNEL}&maxResults=25&metrics=views&sort=-views&startDate=2014-05-01&key={MY_API_KEY}
Here is the result:
200
- Show headers -
{
"kind": "youtubeAnalytics#resultTable",
"columnHeaders": [
{
"name": "insightTrafficSourceDetail",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "views",
"columnType": "METRIC",
"dataType": "INTEGER"
}
],
"rows": [
[
"vk.com",
2399
],
[
"unknown",
872
],
[
"yandex.ru",
23
]
But when I try to write the request into the browser address bar directly, it says:
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"errors": [
{
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"domain": "global",
"reason": "unauthorized"
}
],
"status": "UNAUTHENTICATED"
}
}
I pushed into the {API_KEY} field from here
But, unfortunately, the result is such as provided above. What am I doing wrong? Can you provide the step-by-step instruction to get the right HTTP-request for my aim, as I counld'nt find it? Thank you!

Requesting Microsoft Graph /users/me/sendMail returns 404

We implemented oauth2 microsoft graph integration using node sdk. Mostly we use it for reading and sending emails. We already have some customers using our integration, but there's one customer that we are not able to get / send emails from his account. we get a 404 for everything we try to do using his access/refresh token.
this is one example:
POST https://graph.microsoft.com/v1.0/users/me/sendMail
Content-type: application/json
Content-length: 512
{
"message": {
"subject": "...",
"body": {
"contentType": "Text",
"content": "..."
},
"toRecipients": [
{
"emailAddress": {
"address": "...#....com"
}
}
],
}
}
And the response we are getting is:
{
"statusCode": 404,
"code": "ResourceNotFound",
"message": "Resource could not be discovered.",
"requestId": "b5f8efca-53ff-4cf1-978e-c4f745fcbbc1",
"date": "2018 - 01 - 20 T23: 13: 27.000 Z",
"body": {
"code": "ResourceNotFound",
"message": "Resource could not be discovered.",
"innerError": {
"request-id": "b5f8efca-53ff-4cf1-978e-c4f745fcbbc1",
"date": "2018-01-20T23:13:27"
}
}
}
Looking for some similar issues, we found Office365 API returns 404 on GetCalendars on some accounts
where they say that the customer's mailbox might not be hosted in Office 365.There's a way to check using the requestId if this is the problem with our request? Or there's a way to find out without needing to ask the customer to try to sign in using OWA?
The URL https://graph.microsoft.com/v1.0/users/me/sendMail isn't correct. It should be https://graph.microsoft.com/v1.0/me/sendMail.

Graph API provision of federated user

I am unable to provision users to a federated domain, say example.org, with Microsoft Graph API.
The url I am sending the POST to is:
https://graph.microsoft.com/v1.0/users
json payload is:
{
"accountEnabled": true,
"city": "Seattle",
"country": "United States",
"department": "Sales & Marketing",
"displayName": "Melissa Darrow",
"givenName": "Melissa",
"jobTitle": "Marketing Director",
"mailNickname": "MelissaD",
"passwordPolicies": "DisablePasswordExpiration",
"passwordProfile": {
"password": "Test1234",
"forceChangePasswordNextSignIn": false
},
"officeLocation": "131/1105",
"postalCode": "98052",
"preferredLanguage": "en-US",
"state": "WA",
"streetAddress": "9256 Towne Center Dr., Suite 400",
"surname": "Darrow",
"mobilePhone": "+1 206 555 0110",
"usageLocation": "US",
"immutableID": "melissab",
"userPrincipalName": "melissab#example.org"
}
What I receive is:
{
"error": {
"code": "Request_BadRequest",
"message": "One or more properties contains invalid values.",
"innerError": {
"request-id": "9e8af7a6-fba2-4a66-8421-19dbfd2c36f1",
"date": "2017-05-12T12:13:22"
}
}
}
please note immutableId can be found in the payload.
Is it possibile to provision such users with the given REST framework?
immutableID must be Base64 encoded (byte[])
Ex:
String immutableId = new String(Base64.encodeBase64("someText".getBytes()));
This is expected behavior. The Graph API does not handle the user sync part. User can be synced using Microsoft Azure Active Directory Sync Tool.
Using graph api you can sync the user from azure to our application.
ex : USER_SYNC_QUERY = "https://graph.microsoft.com/v1.0/users?$top=100&$count=true";
1) On each request graph api will send you a #odata.nextLink parameter i.e the skip token for getting next users if more than requested user is present in your azure.
2) By passing the skip token with each request you can sync all the users form azure to your application

Resources