Menu
Home
Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
VB.NET
VB.NET General Discussion
Issue with JSON POST using WebClient
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="digitaldrew" data-source="post: 184737" data-attributes="member: 41941"><p>I don't know if this will be much help, but they put a small example on <a href="https://www.yay.com/blog/api/beginners-guide-part-1/">this page</a> which uses the same endpoint as my initial GET (/authenticated) and they include a few other things in their header (although they never specify it's required)..Here is what theirs looks like:</p><p></p><p>[CODE]</p><p>X-Auth-Reseller: reseller</p><p>X-Auth-User: user</p><p>X-Auth-Password: password</p><p>Host: api.yay.com</p><p>Connection: close</p><p>User-Agent: MyAPIApp 1.0</p><p>[/CODE]</p><p></p><p>So I decided to add the others into my code:</p><p></p><p>[CODE]</p><p>Using webClient As New System.Net.WebClient</p><p> webClient.Headers("User-Agent") = "MyAPIApp 1.0"</p><p> webClient.Headers("Content-Type") = "application/json"</p><p> webClient.Headers("Host") = hostName</p><p> webClient.Headers("Connection") = "close"</p><p> webClient.Headers("X-Auth-Reseller") = txtxAuthReseller.Text</p><p> webClient.Headers("X-Auth-User") = txtxAuthUser.Text</p><p> webClient.Headers("X-Auth-Password") = txtxAuthPassword.Text</p><p></p><p>Dim result As String = webClient.UploadString("https://" & hostName & "/dom/name-server-group", "{""group_name"" : ""Default Name Servers"", ""is_default"" : true, ""name_servers"" : [""" & txtNS1.Text & """, """ & txtNS2.Text & """]}")</p><p>MsgBox(result)</p><p>End Using</p><p>[/CODE]</p><p></p><p>When adding the Connection header I now get the follow error instead of a 500 Internal Server Error: <strong>An exception occurred during a WebClient request.</strong> Once I remove the connection part, it's back to 500 Internal Server Error..</p><p></p><p>Feeling a bit lost.. I've done a POST with JSON in the past and didn't have nearly the trouble I am this time around. I'm not that great with headers, but once I could do the GET I thought for sure the POST wouldn't be too difficult.</p></blockquote><p></p>
[QUOTE="digitaldrew, post: 184737, member: 41941"] I don't know if this will be much help, but they put a small example on [URL="https://www.yay.com/blog/api/beginners-guide-part-1/"]this page[/URL] which uses the same endpoint as my initial GET (/authenticated) and they include a few other things in their header (although they never specify it's required)..Here is what theirs looks like: [CODE] X-Auth-Reseller: reseller X-Auth-User: user X-Auth-Password: password Host: api.yay.com Connection: close User-Agent: MyAPIApp 1.0 [/CODE] So I decided to add the others into my code: [CODE] Using webClient As New System.Net.WebClient webClient.Headers("User-Agent") = "MyAPIApp 1.0" webClient.Headers("Content-Type") = "application/json" webClient.Headers("Host") = hostName webClient.Headers("Connection") = "close" 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://" & hostName & "/dom/name-server-group", "{""group_name"" : ""Default Name Servers"", ""is_default"" : true, ""name_servers"" : [""" & txtNS1.Text & """, """ & txtNS2.Text & """]}") MsgBox(result) End Using [/CODE] When adding the Connection header I now get the follow error instead of a 500 Internal Server Error: [B]An exception occurred during a WebClient request.[/B] Once I remove the connection part, it's back to 500 Internal Server Error.. Feeling a bit lost.. I've done a POST with JSON in the past and didn't have nearly the trouble I am this time around. I'm not that great with headers, but once I could do the GET I thought for sure the POST wouldn't be too difficult. [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
VB.NET
VB.NET General Discussion
Issue with JSON POST using WebClient
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom