如何使用 REST API 和 .Net (C# /VB) 下载 LiveLink (OpenText) 文件

How to download a LiveLink (OpenText) file using REST API and .Net (C# /VB)

使用 LiveLink Server 16.2.9 (2019-06),内部版本 851

这是我用来下载名为 Active_Time.xlsx 的 LiveLink 文件的代码。 如果我在浏览器中粘贴下面的 link,则会下载该文件。但是,当使用此代码时,结果是一个小 XML 文件(见底部)

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

已下载某些内容,但不是我预期的 Excel 文件。这是我用记事本编辑文件时得到的结果。

<!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>

您似乎未通过身份验证? 你应该使用其余的 api.

示例

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