TahirWaheed-9990 avatar image
0 Votes"
TahirWaheed-9990 asked

Converting Curl command to Httpwebrequest in

Hello Everyone,

I am new to!

I would like to convert this command to HTTPwebrequest in At first I want to test it locally and then run it from within docker.
However I am doing something wrong here and can't even test it locally.

 curl --location --request POST "http://ip:port/copy" --header "Content-Type: application/json" --data-raw "{"file":"//path/Testfile.xlsx"}" >> Testfile.xlsx

I have read a few posts on the internet and tried the following.

 Imports System.IO
 Imports System.Net
 Imports System.Text
 Module Module1
     Sub Main()
         Dim request As WebRequest
         request = WebRequest.Create("http://ip:port/copy")
         Dim response As WebResponse
         Dim postData As String = "{"file":"//path/Testfile.xlsx"}" >> Testfile.xlsx"
         Dim data As Byte() = Encoding.UTF8.GetBytes(postData)
         request.Method = "POST"
         request.ContentType = "application/json"
         request.ContentLength = data.Length
         Dim stream As Stream = request.GetRequestStream()
         stream.Write(data, 0, data.Length)
         response = request.GetResponse()
         Dim sr As New StreamReader(response.GetResponseStream())
     End Sub
 End Module

But I am not able to compile and run it because I am stuck at defining the correct data syntax which needs to be posted.
Am I not using the correct code ? please help me out in converting the mentioned curl command to
Thanks in Advance

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers