Http Post With Body

前端 未结 5 411
轻奢々
轻奢々 2020-12-13 15:36

i have sent method in objective-c of sending http post and in the body i put a string:

NSString *requestBody = [NSString stringWithFormat:@\"mystring\"];
NSM         


        
5条回答
  •  孤街浪徒
    2020-12-13 16:25

     ArrayList nameValuePairs = new ArrayList();
    

    then add elements for each pair

     nameValuePairs.add(new BasicNameValuePair("yourReqVar", Value);
     nameValuePairs.add( ..... );
    

    Then use the HttpPost:

    HttpPost httppost = new HttpPost(URL);
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    

    and use the HttpClient and Response to get the response from the server

提交回复
热议问题