Click here to Skip to main content
15,886,919 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Scanner Device Pin
Victor Nijegorodov19-Jul-23 2:04
Victor Nijegorodov19-Jul-23 2:04 
QuestionAll digits in string after W Pin
Dennis B. Muth6-Jul-23 19:41
Dennis B. Muth6-Jul-23 19:41 
AnswerRe: All digits in string after W Pin
Richard MacCutchan6-Jul-23 22:01
mveRichard MacCutchan6-Jul-23 22:01 
AnswerRe: All digits in string after W Pin
Richard Deeming6-Jul-23 22:01
mveRichard Deeming6-Jul-23 22:01 
GeneralRe: All digits in string after W Pin
jschell7-Jul-23 11:49
jschell7-Jul-23 11:49 
GeneralRe: All digits in string after W Pin
Richard Deeming9-Jul-23 21:16
mveRichard Deeming9-Jul-23 21:16 
GeneralRe: All digits in string after W Pin
jschell10-Jul-23 3:34
jschell10-Jul-23 3:34 
QuestionCURL POST request in VB.NET (json) Pin
Member 118569042-Jul-23 20:02
Member 118569042-Jul-23 20:02 
I've been struggling to send this CURL request in VB.NET and hope someone can help..

Here is a link to the documentation of the exact request I'm trying to send.

This is the sample CURL request:
curl -u 'username:token' 'https://api.dev.name.com/v4/domains' -X POST -H 'Content-Type: application/json' --data '{"domain":{"domainName":"example.org"},"purchasePrice":12.99}'


Here is the code that I put together and tested:
Dim uri As New Uri("https://api.dev.name.com/v4/domains")
Dim myUsername As String = txtUsername.Text.Trim & ":" & txtApiKey.Text.Trim
Dim data As String = "{""domain"":{""domainName"":""example.org""},""purchasePrice"":12.99}"
Dim dataByte As Byte()

request = WebRequest.Create(uri)
request.Headers.Add(HttpRequestHeader.Authorization, "Basic " & Convert.ToBase64String(Encoding.UTF8.GetBytes(myUsername)))
request.ContentType = "application/json"
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"
request.Method = "POST"

dataByte = Encoding.UTF8.GetBytes(data)
request.GetRequestStream.Write(dataByte, 0, dataByte.Length)

Dim myResp As HttpWebResponse
myResp = request.GetResponse()
Dim myreader As New System.IO.StreamReader(myResp.GetResponseStream)
WebResponse = myreader.ReadToEnd()

MsgBox(WebResponse)


However, the code above always returns a (400) Bad Request.

Here is another variation of pretty much the same code which I tried:
Dim myReq As HttpWebRequest
Dim myResp As HttpWebResponse
Dim myUsername As String = "username:token"

myReq = HttpWebRequest.Create("https://api.dev.name.com/v4/domains")

myReq.Method = "POST"
myReq.ContentType = "application/json"
myReq.Headers.Add("Authorization", "Basic " & Convert.ToBase64String(Encoding.UTF8.GetBytes(myUsername)))

Dim myData As String = "{""domain"":{""domainName"":""example.org""},""purchasePrice"":12.99}"
Dim dataBytes As Byte() = Encoding.UTF8.GetBytes(myData)
myReq.GetRequestStream.Write(dataBytes, 0, dataBytes.Length)

myResp = myReq.GetResponse()
Dim myreader As New System.IO.StreamReader(myResp.GetResponseStream)
WebResponse = myreader.ReadToEnd()

MsgBox(WebResponse)



But, as you can already guess, it also returns a 400 (Bad Request).
AnswerRe: CURL POST request in VB.NET (json) Pin
Andre Oosthuizen3-Jul-23 0:38
mveAndre Oosthuizen3-Jul-23 0:38 
GeneralRe: CURL POST request in VB.NET (json) Pin
Member 118569043-Jul-23 22:37
Member 118569043-Jul-23 22:37 
GeneralRe: CURL POST request in VB.NET (json) Pin
Andre Oosthuizen3-Jul-23 23:22
mveAndre Oosthuizen3-Jul-23 23:22 
Questionrecord device!! Pin
Member Alienoiz19-Jun-23 6:31
Member Alienoiz19-Jun-23 6:31 
AnswerRe: record device!! Pin
Richard MacCutchan19-Jun-23 6:50
mveRichard MacCutchan19-Jun-23 6:50 
GeneralRe: record device!! Pin
Member Alienoiz19-Jun-23 7:08
Member Alienoiz19-Jun-23 7:08 
GeneralRe: record device!! Pin
Member Alienoiz19-Jun-23 8:30
Member Alienoiz19-Jun-23 8:30 
GeneralRe: record device!! Pin
Richard MacCutchan19-Jun-23 9:12
mveRichard MacCutchan19-Jun-23 9:12 
GeneralRe: record device!! Pin
Member Alienoiz19-Jun-23 9:34
Member Alienoiz19-Jun-23 9:34 
AnswerRe: record device!! Pin
Ralf Meier20-Jun-23 4:05
mveRalf Meier20-Jun-23 4:05 
QuestionListbox Highlight color! Pin
Member Alienoiz18-Jun-23 5:26
Member Alienoiz18-Jun-23 5:26 
AnswerRe: Listbox Highlight color! Pin
Richard MacCutchan18-Jun-23 5:40
mveRichard MacCutchan18-Jun-23 5:40 
GeneralRe: Listbox Highlight color! Pin
Member Alienoiz18-Jun-23 6:00
Member Alienoiz18-Jun-23 6:00 
GeneralRe: Listbox Highlight color! Pin
Richard MacCutchan18-Jun-23 6:39
mveRichard MacCutchan18-Jun-23 6:39 
GeneralRe: Listbox Highlight color! Pin
Member Alienoiz18-Jun-23 6:49
Member Alienoiz18-Jun-23 6:49 
GeneralRe: Listbox Highlight color! Pin
Member Alienoiz18-Jun-23 7:08
Member Alienoiz18-Jun-23 7:08 
GeneralRe: Listbox Highlight color! Pin
Member Alienoiz18-Jun-23 7:47
Member Alienoiz18-Jun-23 7:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.