Curl post request in vb.net

Dim url = String.Format(“http://cr.warehouse.space/api/v1/new_order/{0}/{1}”, objCratejoy.AppID, objCratejoy.SecretKey)

Dim data As String = “{“”id””:” + shp + “}”

Dim myReq As WebRequest = WebRequest.Create(url)
myReq.Method = “POST”
myReq.ContentLength = data.Length
myReq.ContentType = “application/json; charset=UTF-8”
‘Dim usernamePassword As String = “YOUR API TOKEN HERE” & “:” & “x”
Dim enc As UTF8Encoding = New UTF8Encoding()
‘myReq.Headers.Add(“Authorization”, “Basic ” & Convert.ToBase64String(enc.GetBytes(usernamePassword)))

Using ds As Stream = myReq.GetRequestStream()
ds.Write(enc.GetBytes(data), 0, data.Length)
End Using

Dim wr As WebResponse = myReq.GetResponse()
Dim receiveStream As Stream = wr.GetResponseStream()
Dim reader As StreamReader = New StreamReader(receiveStream, Encoding.UTF8)
Dim content As String = reader.ReadToEnd()
Response.Write(content)

Leave a Reply

Your email address will not be published. Required fields are marked *