c# - Post an image with HTTPClient but also some parameters on windows phone -


i want multipartformdatacontent request. want pass lot of params it. when i'm doing post this:

 public async task<webservice> invitemembrs(list<keyvaluepair<string, string>> values)         {             string strurl = string.format("http://*****.com/nl/webservice/abc123/members/invite");             var http = new httpclient();             var request = new httprequestmessage(httpmethod.post, new uri(strurl));             request.content = new httpformurlencodedcontent(values);             var result = await http.sendrequestasync(request);             var data = new webservice { status = result.statuscode };             if (result.statuscode == windows.web.http.httpstatuscode.ok && result.content != null)             {                 data.data = await result.content.readasstringasync();                 debug.writeline(data.data);             }             return data;         } 

this works perfect. want pass image it. found lot of examples without params. can help?

try following code:

httpclient httpclient = new httpclient();  multipartformdatacontent content = new multipartformdatacontent();  content.add(new stringcontent(parameter), "name");  content.add(new streamcontent(stream), "param", "filename");  httpresponsemessage httpresponsemessage = await httpclient.postasync(address, content); 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -