使用HTTP客户端发出POST请求

时间:2019-04-22 11:05:40

标签: c# httprequest httpclient

我正在尝试通过http客户端发出http Web请求,并通过Dictionary<string,object>作为参数具有图像字节数组的方式

但是我无法使用FormUrlEncodedContent编码内容,因为它给了我

“无法从System.Collections.Generic.Dictionary<string, object>转换为System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, string>

是否有其他建议的方法来传递许多不同类型的参数(字符串,字节数组)

这是我的代码的片段!

   var Imagesvalues = new Dictionary<string, object>
{


   { "propertyid", newpropertyID },
    { "image", imageArray },
                { "featured", isFeatured }

                };


                var finalcontent = new FormUrlEncodedContent(Imagesvalues);



                response = await client.PostAsync("http://localhost/modon/addimage", finalcontent);
                featuresindex = featuresindex + 1;

0 个答案:

没有答案
相关问题