UiPath download and upload files to any website via (HTTP request)

How to Download and Upload files to any website via HTTP Request.

0:00​ Intro
0:50VB.NET code to Upload a file to any website
2:25​ Use VB.NET code inside UiPath Studio
2:50​ Implement the code in C#
3:45​ Download files general idea
4:10​ Download via UI and move the file from the Download folder to your folder
5:10​ The main idea how to approach a download of the file
6:05VB.NET code to download the file from any website
7:05​ Run the code and move everything to UiPath studio
8:15​ Use-case with the name of file not fixed
11:10​ Subscriber to my channel

Code for Upload:

Blockquote
Dim client2 As HttpClient = New HttpClient()
Dim filebytes As Byte() = File.ReadAllBytes(“c:\yourfile.docx”)
Dim urilink As Uri = New Uri(“https://yoururl”)
Dim request2 As ByteArrayContent = New ByteArrayContent(filebytes)
request2.Headers.ContentType = New MediaTypeHeaderValue(“application/octet-stream”)
Dim response2 As HttpResponseMessage = client2.PostAsync(urilink, request2).Result
Dim stat As String = response2.StatusCode.ToString

Code for Download:

Blockquote
Dim httpRequest As HttpWebRequest = DirectCast(WebRequest.Create(“https://url.pdf”), HttpWebRequest)
httpRequest.Method = WebRequestMethods.Http.Get
Dim httpResponse As HttpWebResponse = DirectCast(httpRequest.GetResponse(), HttpWebResponse)
Dim httpResponseStream As Stream = httpResponse.GetResponseStream()
Dim doc As Byte()
Dim ms As MemoryStream = New MemoryStream()
httpResponseStream.CopyTo(ms)
doc = ms.ToArray()
File.WriteAllBytes(“C:\yourfile.pdf”, doc)