2

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

1
  • Not a lot I have been reading up on it but do not know where to start, I know not the best way to do this, but I didnt know what else to do, I am unsure how even to do a HTTP Post request with a string value. Commented May 27, 2011 at 15:12

1 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I tired this but how do I collect the returned Json value?
@user the MSDN example is doing that. I'll edit my answer to cover that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.