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>
Looks like you're not authenticated? You should use the rest api.
Example
https://<server.ext>/<livelink-root>/api/v2/nodes/2000
I am (partially) answering my own question. I was able to authenticate and get an authentication "ticket", something like this:
"{""ticket"":""eYrkZQwAH\/DAvyGUEuHbLLU4UFsd6CBi\/GntvBwpXwq0MEPBbyGV9PzFjD7BZNyIpd09kvAQnmkkpX8lRPbksRwVQJSED8kh4JioC5eYVPjJCpKMJxFD0A==""}"
I need some help showing how to use this ticket in order to download a file. Please help resolving the 2-nd part of the problem
This is the code I've written so far:
Dim remoteUri As String = "https://ourserver/livelink/livelink.exe/api/v1/auth"
Dim request As HttpWebRequest = DirectCast(HttpWebRequest.Create(remoteUri), HttpWebRequest)
request.Method = "post"
request.ContentType = "application/x-www-form-urlencoded; charset=utf-8"
Dim postData As String
postData = "username=" & username & "&password=" & password
Dim encoding As New System.Text.UTF8Encoding()
Dim byteArray As Byte() = encoding.GetBytes(postData)
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
dataStream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
If responseFromServer = "0" Then
MsgBox("Successful auth")
Else
MsgBox("Auth failed")
End If
reader.Close()
dataStream.Close()
response.Close()
Dim ticket As String = Mid(responseFromServer, InStr(responseFromServer, "ticket") + Len("ticket") + 3, InStr(responseFromServer, "}") - InStr(responseFromServer, ":") - 3)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.