user101010101
user101010101

Reputation: 1659

HTTP POST with JSON object returned c#

I am trying to create a HTTP Post that returns a JSON object with 2 attributes.

Details are below:

HTTP POST to http://text-processing.com/api/sentiment/ with form encoded data which contains a string. A JSON object response with 2 attributes is retuned; lable and negative.

I am tying to do this in c#, which is where I am struggling.

Thank you

Upvotes: 2

Views: 3615

Answers (1)

Bala R
Bala R

Reputation: 109007

You can try using a WebClient like this

WebClient webclient = new WebClient();
NameValueCollection postValues = new NameValueCollection();
postValues.Add("foo", "fooValue");
postValues.Add("bar", "barValue");
byte[] responseArray = webclient.UploadValues(*url*, postValues);
string returnValue = Encoding.ASCII.GetString(responseArray);

MSDN page also has an example.

Upvotes: 7

Related Questions