Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
DefaultHttpClient httpclient = new DefaultHttpClient();
// Create Request parameters list
ArrayList<namevaluepair> postParameters = new ArrayList<namevaluepair>();
postParameters.add(new BasicNameValuePair("INSTITUTION_ID", "isntitution_id"));
postParameters.add(new BasicNameValuePair("AGGREGATOR_ID", "aggregator_id"));
postParameters.add(new BasicNameValuePair("MEMBER_ID", "member_id"));
postParameters.add(new BasicNameValuePair("PASSWORD", "password"));
postParameters.add(new BasicNameValuePair("inputJson_", "json string"));
// Open new POST Request connection for the “url”
HttpPost httpPost = new HttpPost("url");
httpPost.setEntity(new UrlEncodedFormEntity(postParameters));
// Execute POST request
HttpResponse response = httpclient.execute(httpPost);

What I have tried:

i am not aware of JAVA Code so i have nothing try
Posted
Updated 17-Jan-18 19:44pm
v2

1 solution

HttpClient httpclient = new HttpClient();   
var postParameters = new List<KeyValuePair<string, string>>();
postParameters.Add(new KeyValuePair<string,string>("INSTITUTION_ID", "isntitution_id");
postParameters.Add(new KeyValuePair<string,string>("AGGREGATOR_ID", "aggregator_id"); 
postParameters.Add(new KeyValuePair<string,string>("MEMBER_ID", "member_id");
postParameters.Add(new KeyValuePair<string,string>("PASSWORD", "password");


postParameters.Add(new KeyValuePair<string,string>("inputJson_", "json string");
// Open new POST Request connection for the "url"
var content = new FormUrlEncodedContent(postParameters);

var response = await httpclient .PostAsync(url, content);

var responseString = await response.Content.ReadAsStringAsync();


Don't just Copy paste the code directly .first debug and identify if you are getting any errors in some lines mentioned above then find out the problem and if you aren't able to solve post your comments and if you find any issues and solved it your own then comment how you resolved as well
 
Share this answer
 
v2
Comments
Alex Schunk 19-Jan-18 9:34am    
KeyValuePair<string, string> is Dictionary... Why use a List?
[no name] 19-Jan-18 9:54am    
Yes you are right.This can be modified.I will modify the same.Thanks for pointing this out.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900