upload JSONobject to web server

I am writing a client application for a networked device. The device requires that control values are changed using html "POST" and sending form data containing a JSON object. The devices has some sample commands using CURL that work fine and I am able to capture the "POSTs" using Wireshark. Here is a capture of a good transaction:

Good Wireshark
I am using VB.NET to write my client application and using WebRequest I can send the value pair but the form data is missing the "json=" part of the data:

Failed Data
This is the code I have so far:

        Using sendto As New Net.WebClient
            Dim param As New Specialized.NameValueCollection
            param.Add(theName, theValue)
            Dim response_bytes = sendto.UploadValues(uri, "POST", param)
            Dim response_body = (New Text.UTF8Encoding).GetString(response_bytes)
        End Using

Open in new window


The server rejects the post and closes the connection.

I have searched but cannot find a way to get this data correct. Any pointers would be much appreciated,
Sid.
Sid PriceSoftware Systems Architect/DesignerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
I would normally start coding POCO's to store the data which are covered by this JSON. Then I would use Newtonsoft.JSON (add the package with nuget).
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rainer JeschorCommented:
Hi,
how do go generate / get
param.Add(theName, theValue)

Open in new window

?

They should look like:
theName = "json"
theValue = "{""value"" : ""1.18""}"
param.Add(theName, theValue)

Open in new window

This should then look identical to your CURL.

HTH
Rainer
0
Sid PriceSoftware Systems Architect/DesignerAuthor Commented:
st5an ... since this client application is very simple I decided to use the system.net.sockets API and generate the mostly fixed HTML header in my code. This has allowed me to resolve my issue.
Sid
0
Sid PriceSoftware Systems Architect/DesignerAuthor Commented:
The answer given by the expert was not a full solution and what I eventually implemented myself resolved the issue.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.