Skip to main content
Skip table of contents

2.7.3.1 Overview

Third party applications can use Thru View API to view files stored on Thru server in a browser by calling URL to Viewing API and supplying prepared parameters.

View API Tool displays an image file or the first page of pdf file in canvas element in browser and executes reporting redirects on success or failure.

View API is available via the following URL : https://thruservername/APITool/1.0/View/<shortId> where shortID is prepared in advance by web service call

String GetViewerRequestKey(Guid sessionId, FTHViewerRequest request)

which will be specified below and represents the following data structure:

CODE
    FTHViewerRequest
    {
        public Guid SessionId,
        public int FileId,
        public string SuccessUrl,
        public string ErrorReportingUrl
    }

Structure fields:

  • SessionId : Unique identifier of the current session.

  • FileId : ID of file for view obtained by previous web service calls.

  • SuccessUrl : Redirect to this URL if viewing is success.

  • ErrorReportingUrl : Redirect to this URL if viewing failed.

If viewing failed, a server returns server error code (see below) using parameter “ThruErrorCode”. If an error occurred and ErrorReportingUrl is not defined, then server throws unhandled exception.

Note: the value of ErrorReportingUrl is not validated. Please ensure this is a valid URL.

Reporting redirect rules:

  • Image successfully displayed: call to 

<SuccessUrl> in iFrame, image is still displayed in a browser tab

  • Image cannot be displayed: redirect to 

<ErrorReportingUrl> in the following format: <ErrorReportingUrl>?ThruErrorCode=<errorCode>

Server error codes
The codes below are passed as parameters to the ErrorReportingUrl in case any error occurs:

1 – SessionId is not a valid session id format. 2 – Unknown SessionId. Provided session identifier does not exist on server 3 – FileId is not valid FileId format 4 – FileId does not reference existing file 5 – FileId references to the file of a type not supported for viewing 6 – View failed. This error code is returned for any error that can’t be detected as other ErrorCode

File formats supported for viewing

  • image files: JPG, PNG, GIF and BMP are supported by all browsers, other image types are supported depending on browser ( see 

https://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support )

  • PDF

Sample File View API URL:
http://test.thruinc.net/APITool/1.0/View/4E2CH827YO6OUUQVMSM3

Sample steps to work with View API

WDSL file for API version 4.0 is located at https://<servername>/ws4/fthservice.asmx?WSDL

  1. Get session id: 

Open() or OpenImmutable() or other Open* calls in Thru API

  1. Get FileId for viewing by using one of the file browsing or search methods.

  2. Provide SuccessUrl and ErrorReportingUrl and fill in the structure 

FTHViewerRequest

  1. Generate ShortId: 

ShortId=GetViewerRequestKey(Guid sessionId, FTHViewerRequest request)

  1. Compose View URL and open browser window with the link: 

https://<serverName>/APITool/1.0/View/<shortId>

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.