0

I am trying to create file handler add in that uses provider hosted application to open custom file.

I have hosted app in heroku and until now i get request body in my application as follows when i open file from sharepoint.

{
  resourceid: "https://{tenant}.sharepoint.com",
  culturename: "en-US",
  fileget: "https://{tenant}.sharepoint.com/_vti_bin/wopi.ashx/files/{fileid}/contents?access_token={token}",
  fileput: "https://{tenant}.sharepoint.com/_vti_bin/wopi.ashx/files/{fileid}/contents?access_token={token}",
  fileid: "{fileid}",
  client: "SharePoint"
}

But when i request to get file content using fileget url. It throws 500 error with message The URL is invalid for the current user or application.

What could be the way to access file content.

duwalanise
  • 1,312
  • 1
  • 14
  • 24

1 Answers1

0

The URL seem to be correct. What you can do is to see the file's URL properties by requesting CheckFileInfo.

Example:

GET https://{tenant}.sharepoint.com/_vti_bin/wopi.ashx/files/{fileid}?access_token={token}

And have a look at DownloadUrl and FileUrl. If any of the properties is set, use them to download the file.

rocky
  • 7,506
  • 3
  • 33
  • 48
  • Hi Rocky, When i send request to the url as above. it throws and error. ```{"error_description":"Exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException' was thrown."}```. I am using postman – duwalanise May 10 '18 at 02:26
  • You might have to compose your own URL using the [discovery XML file](https://onenote.officeapps.live.com/hosting/discovery) of your WOPI client instance. It might be slightly different from the one above. Make sure you have the right endpoint (= correct app name, correct action). Plus, did you also try looking at DownloadUrl and FileUrl as I suggested? – rocky May 10 '18 at 13:27
  • I didn't get any other properties except those written above.I am very new to sharepoint and could not get what you are actually pointing out. I was following the filehandler docs and was supposed to get activation parameters as described [here](https://learn.microsoft.com/en-us/onedrive/developer/file-handlers/#activation-parameters) – duwalanise May 10 '18 at 13:46