首页 > 解决方案 > How to download a LiveLink (OpenText) file using REST API and .Net (C# /VB)

问题描述

Using LiveLink Server 16.2.9 (2019-06), build 851

This is the code I use to download a LiveLink file named Active_Time.xlsx. If I paste the link below in the browser, then the file is downloaded. However, when using this code the result is a small XML file (see bottom)

Dim remoteUri As String = "https://OurServer.com/livelink/livelink.exe?func=ll&objId=33100345&objAction=download"

Using client = New Net.WebClient()
      client.Credentials = New Net.NetworkCredential(username, password, domain)
      client.DownloadFile(remoteUri, "C:\temp\Active_Time.xlsx)           
      Console.WriteLine("File extracted.")
      client.Dispose()
    End Using

Something is downloaded but not the Excel file I expected. This is what I get if I edit the file with Notepad.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <script src="./jquery.min.js?v=16.6.0.2315"></script>
    <script src="./login1/getfragment.js?v=16.6.0.2315"></script>
</head>
<body>
<noscript>
    <p><strong>Note:</strong>Since your browser does not support Javascript, you must press the Continue button once to proceed.</p>
</noscript>
<form action="login" method="get">
<div>

    <input type="hidden" name="RFA" value="eyJhbGciOiJub25lIn0.eyJwb3N0VGlja2V0Ijp0cnVlLCJwb3N0UGFyYW1zIjp0cnVlLCJsb2dvblN0eWxlIjoic2lnbmluLWNzIiwidXhWZXJzaW9uIjoxLCJmb3J3YXJkQWRkcmVzcyI6Imh0dHBzOi8vY2Rtcy50YXMtY2FuLmNvbS9saXZlbGluay9saXZlbGluay5leGU_ZnVuYz1vdGRzaW50ZWdyYXRpb24ucmVkaXJlY3QmTmV4dFVSTD1odHRwcyUzQSUyRiUyRmNkbXMlMkV0YXMlMkRjYW4lMkVjb20lMkZsaXZlbGluayUyRmxpdmVsaW5rJTJFZXhlJTNGZnVuYyUzRGxsJTI2b2JqSWQlM0QzMzY1MjI3MSUyNm9iakFjdGlvbiUzRGRvd25sb2FkJTI2bmV4dHVybCUzRCUyNTJGbGl2ZWxpbmslMjUyRmxpdmVsaW5rJTJFZXhlJTI1M0ZmdW5jJTI1M0RsbCUyNTI2b2JqSWQlMjUzRDMzMTQwMzE1JTI1MjZvYmpBY3Rpb24lMjUzRGJyb3dzZSUyNTI2bG9nU3RvcENvbmRpdGlvbklEJTI1M0QxMTYwODAxXzEzOTA1Mzg5MF8xX2xvYyIsInJlc291cmNlSUQiOiIxYTEzYzg2Mi0zZGY2LTRhNGYtYWU3MC1kYThhNmY0ZGI4YzIifQ">

    <input type="hidden" name="fragment" id="fragment">
</div>
<noscript>
    <div><input type="submit" value="Continue"></div>
</noscript>
</form>
</body>

标签: opentextlivelink

解决方案


看起来你没有通过身份验证?您应该使用其余的 api。

例子

https://<server.ext>/<livelink-root>/api/v2/nodes/2000

推荐阅读