ErrorInternalServerError Getting mine content - microsoft-graph-api

I am trying to get content (MIME) of an email via Microsoft Graph Api:
var mime = await _graphClient.Users [user] .Messages [mailid] .Content.Request (). GetAsync ();
for some users I'm get this error:
enter image description here
Code: ErrorInternalServerError
Message: An internal server error occurred. The operation failed.
ClientRequestId: bd559710-a820-4c37-b386-fea7a72f3eec

Related

Invalid Request 409 when trying to subscribe to Microsoft Graph for Presence

Executing a subscription to presence request for users with the SDK targeting the MS Graph API is resulting in an error:
409Graph service exception Error code: InvalidRequest
Throwable detail: com.microsoft.graph.http.GraphServiceException: Error code: InvalidRequest
Error message: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
POST https://graph.microsoft.com/v1.0/subscriptions
SdkVersion : graph-java/v5.16.0
SdkVersion : graph-java/v5.16.0
[...]
400 : Bad Request
[...]
My code is:
final Subscription subscriptionRequest = new Subscription();
subscriptionRequest.changeType = ChangeType.UPDATED.toString();
subscriptionRequest.notificationUrl = notificationsHost;
subscriptionRequest.resource = "/communications/presences?$filter=id in ("+userIdsSb.toString()+")";
subscriptionRequest.clientState = subscribeToPresenceRequest.getClientState();
}el
subscriptionRequest.clientState = UUID.randomUUID().toString();
subscriptionRequest.expirationDateTime = OffsetDateTime.now().plusHours(1);
Subscription subscription = null;
try {
subscription = graphClient.subscriptions().buildRequest().post(subscriptionRequest);
response.setSubscribed(false);
failedIds.addAll(this.getFailedIds(e));
log.error("Error while trying to execute subscribeToPresence. ", e);
if(failedIds!=null && !failedIds.isEmpty()) {
log.error("The ids {} failed during the subscription request ",failedIds);
response.setFailedIds(failedIds);
}
}catch(Exception e) {
log.error("General Error while trying to execute subscribeToPresence. ", e);
retur
}
My subscription request includes the following values:
applicationId: null
changeType: UPDATED
clientState: 7fc6bf6b-6cc2-438d-a293-aa47539ad02a
creatorId: null
id: null
latestSupportedTlsVersion: null
lifecycleNotificationUrl: null
notificationQueryOptions: null
notificationUrl: https://myhost:port/graph/listen
notificationUrlAppId: null
oDataType: null
resource: /communications/presences?$filter=id in ('932b90ca-e5a4-42c7-a985-f4ddfc6d6715','6be2455d-63ac-4423-aa3e-7188fdbd5e73','41b3d168-5c28-4596-ba3b-d5c70a3c3967','8830a8bc-f882-4c13-b33a-7031423b5a24','ab548af7-d5a9-4388-9800-7668a20bb2b9')
expirationDateTime: 2023-02-02T16:41:11.737+02:00
includeResourceData: false
I saw this article regarding the beta version of the sdk https://learn.microsoft.com/en-us/graph/api/resources/subscription?view=graph-rest-1.0.
It indicates "Subscriptions to resources marked with an asterisk (*) are available on the /beta endpoint only." and presence is one of those resources. Is this related to my error?
I tried to use this version instead, but I still have the same Invalid request error.
I am using delegated permission to call the /subscription/presence endpoint of the Microsoft Graph API.
I was able to fetch previous subscriptions by calling /subscription endpoint and was also able to find users through /users/filter endpoint with application permission.
Is there something wrong in the format of my subscription request? This all worked fine a few months ago and I haven't changed anything.
Is this related to SSL/TLS secure communication? But then again, why would my other requests get responses?

Microsoft.Graph.Core create subscription "Access denied"

Following this walkthrough, I'm able to get a "subscription" on my Azure Function to a users mailbox.
However when I modify it to try to access a users onedrive, I'm able to access their files in the app, but when attempting to subscribe for a webhook I get the error below. I verified my token has Files.ReadWrite.All permission so I don't understand what I'm missing.
[2020-11-19T16:17:12.327Z] Executed 'SetDocSubscription' (Failed, Id=01410f60-0954-4e37-b9aa-2940cf9d0a17, Duration=2177ms)
[2020-11-19T16:17:12.330Z] System.Private.CoreLib: Exception while executing function: SetDocSubscription. Microsoft.Graph.Core: Code: ExtensionError
[2020-11-19T16:17:12.331Z] Message: Operation: Create; Exception: [Status Code: Forbidden; Reason: Access denied]
[2020-11-19T16:17:12.332Z] Inner error:
[2020-11-19T16:17:12.333Z] AdditionalData:
[2020-11-19T16:17:12.334Z] date: 2020-11-19T16:17:11
[2020-11-19T16:17:12.335Z] request-id: ccd648e7-b3fc-43f6-b1c5-481cbb5dcab6
[2020-11-19T16:17:12.336Z] client-request-id: ccd648e7-b3fc-43f6-b1c5-481cbb5dcab6
[2020-11-19T16:17:12.337Z] ClientRequestId: ccd648e7-b3fc-43f6-b1c5-481cbb5dcab6
...additional detail, calling function looks like this:
// Create a new subscription object
var subscription = new Subscription
{
ChangeType = "updated",
NotificationUrl = $"{notificationHost}/api/DocsNotify",
Resource = $"/users/{payload.UserId}/drive/root/",
ExpirationDateTime = DateTimeOffset.UtcNow.AddDays(2),
ClientState = Notify.ClientState
};
// POST /subscriptions
var createdSubscription = await graphClient.Subscriptions
.Request()
.AddAsync(subscription);
return new OkObjectResult(createdSubscription);
I am suspecting you're exceeding the limits here. When any limit (it can be Azure AD resource limitation as well) is
exceeded, attempts to create a subscription will result in an error
response - 403 Forbidden.
You can see the above error. In your
scenario, you will see the message property which will explain which
limit has been exceeded.
Here's the related doc.

Google Places API Autocomplete not working bad request

I'm trying to use Google places API to get autocomplete.
I've checked everything:
API keys are activated (disabled every restriction)
I'm calling GMSServices.provideAPIKey and GMSPlacesClient.provideAPIKey
Initializing the object placesClient = GMSPlacesClient.shared()
The call I'm making is:
let filter = GMSAutocompleteFilter()
filter.type = .establishment
placesClient?.autocompleteQuery(textField.text!, bounds: nil, filter: filter) { (predictionList, error) in
if let error = error {
print("Pick Place error: \(error.localizedDescription)")
return
}
if let list = predictionList{
self.resultList = list
}
}
The error I'm getting is:
Printing description of error: Error
Domain=com.google.places.ErrorDomain Code=-3 "An internal error
occurred in the Places API library. If you believe this error
represents a bug, please file a report using the instructions on our
community and support page
(https://developers.google.com/places/support)."
UserInfo={NSLocalizedFailureReason=An internal error occurred in the
Places API library. If you believe this error represents a bug, please
file a report using the instructions on our community and support page
(https://developers.google.com/places/support).,
NSUnderlyingError=0x608000445370 {Error
Domain=com.google.places.server.ErrorDomain Code=-1 "(null)"
UserInfo={NSUnderlyingError=0x60800024f030 {Error
Domain=com.google.GTLRErrorObjectDomain Code=400 "(Bad Request)"
UserInfo={error=Bad Request, GTLRStructuredError=GMSx_GTLRErrorObject
0x60800024f9f0: {message:"Bad Request" errors:[1] code:400},
NSLocalizedFailureReason=(Bad Request)}}}}}
Has anyone else seen this problem in Xcode 8 iOS 10? Thanks
EDIT: Now it seems that some requests are working... Maybe the server is having problems?

Google Blogger API is returning 403 error

I am developing an iOS app to show the public posts from my blog/website. As suggested in Google Developer Guidelines, Created the iOS Public API key under “Google Developers Console” and included GTL Client library and required sources in my project. Also enabled the blogger V3 API in Google Developer Console.
When I execute the query to get the blog using blogID reports following error:
An Error Occurred! Error Domain=com.google.GTLJSONRPCErrorDomain Code=403 "(Insufficient Permission)" UserInfo={error=Insufficient Permission, NSLocalizedFailureReason=(Insufficient Permission), GTLStructuredError=GTLErrorObject 0x7fe743766030: {message:"Insufficient Permission" data:[1] code:403}}
Code Snippest:
let bloggerService : GTLServiceBlogger = GTLServiceBlogger()
override func viewDidLoad() {
super.viewDidLoad()
self.bloggerService.authorizer = GTMOAuth2ViewControllerTouch.authForGoogleFromKeychainForName(kKeychainItemName as String, clientID: kClientID, clientSecret: nil)
bloggerService.APIKey = kAPIKey;
let query : GTLQueryBlogger = GTLQueryBlogger.queryForBlogsGetWithBlogId(kBlogID)
self.bloggerService.executeQuery(query, completionHandler: { (ticket, blogList , error) -> Void in
if error == nil {
print("Blog list = \(blogList)")
} else {
print("An Error Occurred! \(error)")
self.showAlert(“Error”, message: "Sorry, an error occurred!")
}
})
If I comment out the authorisation code(self.bloggerService.authorizer = GTMOAuth2ViewControllerTouch.authForGoogleFromKeychainForName(kKeychainItemName as String, clientID: kClientID, clientSecret: nil)), the error will be different:
An Error Occurred! Error Domain=com.google.GTLJSONRPCErrorDomain Code=403 "(There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referrer should be allowed.)" UserInfo={error=There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referrer should be allowed., NSLocalizedFailureReason=(There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referrer should be allowed.), GTLStructuredError=GTLErrorObject 0x7fe41945b170: {message:"There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referrer should be allowed." data:[1] code:403}}
Can somebody please help me to resolve this issue?
Note: Actually when I run this HTTP request in Google API Explorer(“https://developers.google.com/apis-explorer/#p/blogger/v3/blogger.blogs.get”), it returns the JSON response.

How to get token_for_business for Facebook login - iOS

How can I get token_for_business from Facebook login? I have setup a business and associated my application with that business. Facebook documentation says you need to call GET /me?fields=token_for_business on User node, and it will return following json.
{
"id": "1234567890"
"token_for_business": "weg23ro87gfewblwjef"
}
I tried by providing token_for_business in parameter list of /me call but didn't work. Need advises.
Edit
I found this URL https://developers.facebook.com/docs/graph-api/reference/v2.5/user and tried by passing token_for_business in param of initWithGraphPath but no gain. I checked in Graph API Explorer and getting the required data. But not sure how to call from my objective-C code.
Edit 2
I Inspected the error object of initWithGraphPath:#"me?fields=token_for_business" call and found following details
Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=403, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=(#200) Application must be associated with a business. https://business.facebook.com/, com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=200, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body = {
error = {
code = 200;
"fbtrace_id" = "EN9bN/YMloA";
message = "(#200) Application must be associated with a business. https://business.facebook.com/";
type = OAuthException;
};
};
code = 403;
}}
But if I try my app in Graph API Explorer then I'm getting the required data. So now it confusing me.

Resources