Click here to Skip to main content
15,887,027 members
Home / Discussions / Visual Basic
   

Visual Basic

 
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 
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 
Hey Andre,
Thanks so much for your detailed reply and explanation! I imported Newtonsoft.json no problem and tried implementing your changes. On a positive note, I'm no longer getting a (400) Bad Request reply. However, I'm now getting a (401) Unauthorized response. I've double checked my login details and made sure they were correct. I also tried testing in both the OTE (operational test environment) and the LIVE environment because the details are slightly different for each, but received the same error on both.

Could this be due to how the credentials are now being passed?

Also, if I close "GetRequestStream" before sending the request then I get a message the connection was suddenly terminated when trying to send the request. However, if I put it directly after writing to the stream that issue goes away. Here is a look at my updated code:
Dim uri As New Uri("https://api.dev.name.com/v4/domains")
Dim domainData As New With {
    .domain = New With {
        .domainName = "example.org"
    },
    .purchasePrice = 12.99
}

Dim data As String = JsonConvert.SerializeObject(domainData)
Dim dataByte As Byte()

request = WebRequest.Create(uri)
request.Credentials = New NetworkCredential(txtUsername.Text.Trim, txtApiKey.Text.Trim)
request.ContentType = "application/json"
request.Method = "POST"

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

Dim myResp As HttpWebResponse
myResp = request.GetResponse()
Dim statusCode As Integer = CType(myResp, HttpWebResponse).StatusCode
Dim responseText As String = String.Empty

If statusCode = HttpStatusCode.OK Then
Dim myreader As New System.IO.StreamReader(myResp.GetResponseStream)
responseText = myreader.ReadToEnd()
End If

MsgBox(responseText)


Any suggestions? Thanks again!
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 
GeneralRe: Listbox Highlight color! Pin
Member Alienoiz18-Jun-23 8:41
Member Alienoiz18-Jun-23 8:41 
GeneralRe: Listbox Highlight color! Pin
Richard MacCutchan18-Jun-23 21:39
mveRichard MacCutchan18-Jun-23 21:39 

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.