[Solved] Converting CURL command to .NET


Here is what I came up with based on the example posted by @M.Hassan

Public Function UPLOAD_FILE(filepath As String) As String
    Dim request As WebRequest = WebRequest.Create("http://localhost:8042/instances ")
    request.Method = "POST"
    Dim byteArray As Byte() = File.ReadAllBytes(filepath)
    request.ContentType = "application/x-www-form-urlencoded"
    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 StreamReader = New StreamReader(dataStream)
    Dim responseFromServer As String = reader.ReadToEnd()
    reader.Close()
    dataStream.Close()
    response.Close()
    Return responseFromServer
End Function

solved Converting CURL command to .NET