I'm messing around with an API that uses JSON, but can't seem to make it POST properly. This particular API authenticates my account using three pieces of information which must be passed in the header. The service offers a basic endpoint you can GET to make sure your information is being passed properly, and when I try that it works fine. However, when I try to POST something it keeps giving me Internal Server errors..
Here is the working GET request which confirms to me that my account info is correct and the headers are being passed properly.
Next, I want to make my first POST request. I need to pass the following JSON:
Here is the POST code I am trying. This gives me: The remote server returned an error: (500) Internal Server Error.
Here is the working GET request which confirms to me that my account info is correct and the headers are being passed properly.
Code:
Dim webClient As New System.Net.WebClient
webClient.Headers("User-Agent") = "MyAPIApp 1.0"
webClient.Headers("X-Auth-Reseller") = txtxAuthReseller.Text
webClient.Headers("X-Auth-User") = txtxAuthUser.Text
webClient.Headers("X-Auth-Password") = txtxAuthPassword.Text
Dim result As String = webClient.DownloadString("https://" & My.Settings.Hostname & "/authenticated")
MsgBox(result)
Code:
{
"group_name" : "Default Name Servers",
"is_default" : true,
"name_servers" : [
"ns1.example.com",
"ns2.example.com"
]
}
Code:
Dim webClient As New System.Net.WebClient
webClient.Headers("User-Agent") = "MyAPIApp 1.0"
webClient.Headers("X-Auth-Reseller") = txtxAuthReseller.Text
webClient.Headers("X-Auth-User") = txtxAuthUser.Text
webClient.Headers("X-Auth-Password") = txtxAuthPassword.Text
Dim result As String = webClient.UploadString("https://" & My.Settings.Hostname & "/dom/name-server-group", "{""group_name"" : ""Default Name Servers"", ""is_default"" : true, ""name_servers"" : [""ns1.sedoparking.com"", ""ns2.sedoparking.com""]}")
MsgBox(result)