CreateFileUploadSession() calls result in "Object reference not set to an instance of an object." response from Graph API - .net-core

I have a website running in production that uploads files on behalf of users. This functionality has been working for months with only transient network issues.
Past two weekdays (Friday and Monday, virtually no usage over the weekend), all users are getting the standard null reference error whenever they try to upload the file. I'm able to produce this in all our environments. The interesting part is that the graph service itself is returning the error message, this is NOT a null reference exception from the website code.
Here is the request URL:
https://graph.microsoft.com:443/beta/groups/[id]/drive/items/[folderId]:/[filename].[ext]:/microsoft.graph.createUploadSession
The [] and content within are placeholders for the values that are sent. I am using the .NET Graph SDK and have verified that it is properly encoding the file name.
The body of the response from the Graph API is:
{
"error": {
"code": "InternalServerError",
"message": "Object reference not set to an instance of an object.",
"innerError": {
"request-id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"date": "2020-02-17T20:10:03"
}
}
}

Related

Getting 400 error while creating "Web Token" when hitting enterprises.webTokens.create endpoint to use iframe in EMM console

We are getting 200 success while hitting endpoints like create signup URL, create enterprise, create enrollment token etc. through API Explorer or Postman. But while we are trying to hit the "create web token" endpoint we are getting 400 error.
We are implementing Google Android Management API. Finally, we are proceeding for implementing iframe which required the web token as it's carrier. But we are failing to do so.
For your reference:
enrollmentTokens.create endpoint Link below:
https://developers.google.com/android/management/reference/rest/v1/enterprises.enrollmentTokens/create
In the API explorer we are providing
parent = enterprises/LC00x1u8p0 and selecting Google OAuth 2.0 credentials.
With this much information API Explorer giving 200 success message.
enterprises.webTokens.create endpoint Link below:
https://developers.google.com/android/management/reference/rest/v1/enterprises.webTokens/create
In the API explorer we are providing
parent = enterprises/LC00x1u8p0 and selecting Google OAuth 2.0 credentials.
With this the same information API Explorer giving 400 error. I have posted the error message and unable to understand where is the error coming.
Is our console cloud project need any special supplement for giving access to web token? or what exactly is the lacking that giving this 400 error?
We are failing to understand the error message. Please check the below response.
​{
"error": {
"code": 400,
"message": "domain: \"gdata.CoreErrorDomain\"\ncode: \"INVALID_VALUE\"\nargument: \"tokenSpec.parent\"\ndebug_info: \"code: INVALID_VALUE\\nhttp status: 400\\narguments: [tokenSpec.parent]\\nvalue: \\ncause: com.google.wireless.android.vending.enterprise.common.exceptions.InvalidParameterException: EnterpriseException{httpStatus=400, code=gdata.CoreErrorDomain.INVALID_VALUE, arguments=[tokenSpec.parent]}\\n\\tat com.google.wireless.android.vending.enterprise.common.exceptions.InvalidParameterException$Builder.build(InvalidParameterException.java:60)\\n\\tat com.google.wireless.android.vending.enterprise.business.EmbeddedUiServiceImpl.validate(EmbeddedUiServiceImpl.java:173)\\n\\tat com.google.wireless.android.vending.enterprise.business.EmbeddedUiServiceImpl.createWebToken(EmbeddedUiServiceImpl.java:123)\\n\\tat com.google.wireless.android.vending.enterprise.actions.mdmapi.EnterpriseActions$CreateWebTokenAction.execute(EnterpriseActions.java:360)\\n\\tat com.google.apps.framework.request.impl.InterceptorInvocation$Rpc.beforeProceed(InterceptorInvocation.java:147)\\n\\tat com.google.apps.framework.request.impl.InterceptorInvocation.proceed(InterceptorInvocation.java:158)\\n\\tat com.google.apps.framework.request.impl.RpcDispatcher.proceed(RpcDispatcher.java:136)\\n\\tat com.google.apps.framework.request.impl.RpcDispatcher.proceed(RpcDispatcher.java:42)\\n\\tat com.google.apps.framework.request.impl.AbstractDispatcher.doExecuteChainInternal(AbstractDispatcher.java:503)\\n\\tat com.google.apps.framework.request.impl.AbstractDispatcher.doExecuteChain(AbstractDispatcher.java:497)\\n\\tat com.google.apps.framework.request.impl.AbstractDispatcher.execute(AbstractDispatcher.java:331)\\n\\tat com.google.apps.framework.request.impl.AbstractDispatcher.executeAsync(AbstractDispatcher.java:254)\\n\\tat com.google.apps.framework.request.impl.RpcDispatcher.handleRpc(RpcDispatcher.java:126)\\n\\tat com.google.apps.framework.request.impl.RpcScopedHandlerFactoryImpl.run(RpcScopedHandlerFactoryImpl.java:276)\\n\\tat com.google.apps.framework.request.impl.RpcScopedHandlerFactoryImpl$2.handleRequest(RpcScopedHandlerFactoryImpl.java:126)\\n\\tat com.google.net.rpc3.impl.server.RpcServerInterceptor2Util$RpcApplicationHandlerAdaptor.handleRequest(RpcServerInterceptor2Util.java:82)\\n\\tat com.google.net.rpc3.impl.server.RpcServerInternalContext.runRpcInApplicationWithCancellation(RpcServerInternalContext.java:672)\\n\\tat com.google.net.rpc3.impl.server.RpcServerInternalContext.lambda$runRpcInApplication$0(RpcServerInternalContext.java:637)\\n\\tat io.grpc.Context.run(Context.java:536)\\n\\tat com.google.net.rpc3.impl.server.RpcServerInternalContext.runRpcInApplication(RpcServerInternalContext.java:637)\\n\\tat com.google.net.rpc3.impl.server.RpcServerChannel$4.apply(RpcServerChannel.java:1026)\\n\\tat com.google.net.rpc3.impl.server.RpcServerChannel$4.apply(RpcServerChannel.java:996)\\n\\tat com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.doTransform(AbstractTransformFuture.java:253)\\n\\tat com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.doTransform(AbstractTransformFuture.java:243)\\n\\tat com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:124)\\n\\tat com.google.common.context.ContextRunnable.runInContext(ContextRunnable.java:89)\\n\\tat com.google.common.context.ContextRunnable$1.run(ContextRunnable.java:78)\\n\\tat io.grpc.Context.run(Context.java:536)\\n\\tat com.google.tracing.GenericContextCallback.runInInheritedContext(GenericContextCallback.java:75)\\n\\tat com.google.common.context.ContextRunnable.run(ContextRunnable.java:74)\\n\\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\\n\\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\\n\\tat com.google.apps.framework.server.AbstractThreadPoolModule$InitializingThreadFactory.lambda$newThread$0(AbstractThreadPoolModule.java:416)\\n\\tat java.base/java.lang.Thread.run(Unknown Source)\\n\\n\"\n",
"status": "INVALID_ARGUMENT"
}
}
Thanks you very much for your attention. Any help to fix the issue is appreciable.
You need to supply the Request body of the enterprises.webTokens.create method. The request body contains an instance of WebToken.
Request body:
{
"parentFrameUrl": "<the URL of the page that will be hosting the iFrame>",
"enabledFeatures": [
"PLAY_SEARCH",
"PRIVATE_APPS",
"WEB_APPS",
"STORE_BUILDER"
],
"permissions": [
"APPROVE_APPS"
]
}
If successful, the response body contains a newly created instance of WebToken containing the value you need to embed the iFrame on the hosting page.

Autodesk forge Webhook API, Error 400 400, VALIDATION_ERROR

using autodesk forge API, I am trying to create a webhook over folder using the following information; unfortunately, I am receiving the following response:
{
"id":"xxxx-xxxx-xxx-xxxxx",
"status":400,
"code":"VALIDATION_ERROR",
"detail":["Payload is not valid for serialization"]
}
URL:
https://developer.api.autodesk.com/webhooks/v1/systems/data/events/dm.folder.added/hooks (for specific folder added event) or: https://developer.api.autodesk.com/webhooks/v1/systems/data/hooks (for all events). Both are returning the same error
Header:
{
"Content-Type":"application/json",
"Authorization":"<MY_TOKEN>",
"x-ads-region":"US"
}
Data:
{
"callbackUrl":"<MY_DOMAIN>:<MY_PORT>/callback",
"scope":{
"folder":"urn:adsk.wipprod:fs.folder:co.xxxxxxxxxxxx-xxxxx"
}
}
Troubleshooting:
I've tried different folders, root and non-root. I can access all the folders i tried using the api
I am sure that my account is US region
I've tried to add hubId and/or projectId, but I received the same error
<MY_DOMAIN>:<MY_PORT>/callback is configured and working fine
Headers and Data are serializing and de-serializing normally using json loads & dumps
Any suggestion/help?
Answering myself :)
I've discovered that my issue is not related to Forge API, it's a general one related to python Requests. The payload (data) of Requests cannot be nested dictionary, only 1 level dictionary is accepted, nested ones will fail. the solution is to stringify the dict (json.dumps) and use that string as request payload.

Deleting Microsoft graph fails with ExtensionError

I am trying to delete a webhook subscription to Microsoft graph.
My http call is:
DELETE https://graph.microsoft.com/v1.0/subscriptions/3ecdf72f-f302-49f6-851c-d04d178a9ref
I got the id of the subscription using:
GET https://graph.microsoft.com/v1.0/subscriptions
As response I am getting this error:
{
"error": {
"code": "ExtensionError",
"message": "Operation: Delete; Exception: [Status Code: NotFound; Reason: Not Found]",
"innerError": {"request-id": "2c61eba9-86c8-4420-9276-d6581fd3c5b7", "date": "2018-10-30T15:11:57"}
}
}
We are investigating a bug where sometimes subscriptions will be orphaned in the system. The actual subscription was originally removed and notifications are not being sent.
You should expect the subscription to be removed properly from the system in the next few days, as we fix the bug. Sorry for any inconvenience.

google cloud vision api quickstart error opening file

I am following the following Google Cloud Vision quickstart:
https://cloud.google.com/vision/docs/quickstart
This is using the API Explorer, and I get
Error Opening File
I have created a bucket named vision2018, and checked Share Publicly for the file.
My portion of the request related to the file is:
"image":
{
"source":
{
"imageUri":"gs://vision2018/demo-image.jpg"
}
}
The response I get is:
{
"responses": [
{
"error": {
"code": 5,
"message": "Error opening file: gs://vision2018/demo-image.jpg\"."
}
}
]
}
}
What do I need to specify in order to access files in my GCP storage?
Alternatively, I read other Stack Overflows that talk about GOOGLE_APPLICATION_CREDENTIALS, Simple API Key, and "Create Service account key and download the key in JSON format", ... but these seem to be giving commands in the shell, which this quickstart doesn't even open.
Is there initial setup assumed prior to the quickstart?
I am not ready to call the api from code
You might want to doublecheck your request. I went to the quickstart, replaced the placeholder imageUri with gs://vision2018/demo-image.jpg and it worked just fine. The error message you posted is what would be displayed if you had given gs://vision2018/demo-image.jpg\" instead.
Regarding the second part of your question: these are authentication methods. In this particular case, under Authentication you will find a drop down which lets you chose between API key and Google OAuth 2.0. If you chose the former, you don't need to do anything as a demo key will be used just for the purposes of the quickstart. If you chose OAuth 2.0, a popup will appear prompting you to authenticate with a google account. All in all, what you need to do is follow step-by-step the instructions given by the quickstart.
I was receiving a similar JSON response from the Google Vision API:
"error": {
"code": 7,
"message": "Error opening file: gs://bucket/file.jpg."
}
The fix was to set the GCS file's permission to public-read:
gsutil acl set public-read gs://bucket/file.jpg
Finally I investigated what happened. The problem is that your API token is only grant for process the image (allow right to use OCR engine), but that API is not also for accessing object in GS.
Therefore "message": "Error opening file:
The problem is similar with this post:Authorize Google Cloud Vision API to Google Storage image Maybe the error message is a bit dumb than many years ago.
The solution also mentioned in the answer section, but if you want some thing more clear (expose security side-effect) here it is: Set GCS read-only public
Reason I want to keep using API because it's better for use it in mobile application, we cannot give the OAuth2.0 to any phone. However, still find a way to secure the read-public bucket.

Registering achievements: Object Base Domain Not Allowed, even when domain IS allowed

I have an Open Graph achievement at the following URL:
http://rinth.bucket1.s3.amazonaws.com/Achievements_LOCAL/Achievement1.html
When I attempt to register it, I get a response of: status code 400: OAuth "Facebook Platform" "invalid_request" "(#3502) Object at achievement URL is not of type game.achievement"
When I bring up the debug tool to have it validate the HTML:
http://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Frinth.bucket1.s3.amazonaws.com%2FAchievements_LOCAL%2FAchievement1.html
I get the following errors:
Object Base Domain Not Allowed: Object at URL 'http://rinth.bucket1.s3.amazonaws.com/Achievements_LOCAL/Achievement1.html' of type 'game.achievement' is invalid because the domain 'rinth.bucket1.s3.amazonaws.com' is not allowed for the specified application id '217132388329112'.
Missing Required Property: The og:url property is required, but not present.
Missing Required Property: The og:type property is required, but not present.
Missing Required Property: The og:title property is required, but not present.
I verified that this domain IS allowed by our application. Just in case, I also tried the entire process using a different domain (which resulted in the exact same error).
The graph URL at the bottom of the debug tool prints the following:
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException"
}
}
Any ideas on what I'm doing wrong?
To fix this problem you have to add "rinth.bucket1.s3.amazonaws.com" to the list of app domains in your application settings.
This security measure is there so that you can only access achievements from domains and applications that you specify.

Resources