简体   繁体   中英

Post complex data type using HttpClient

I need to post an object of class like>

    class A{
        public string dataitem1{get;set;}
        public byte[] dataitem2{get;set;}

 }

I need to post the object of this class to webAPI using Windows Store App 8.1. I tried many solutions but could not find anyone working. Can somebody provide help by code or link to working demo. I'm trying to implement full MVVM structure

I Found one demo here but not working in my case

By converting the object into a json string you can transfer the json object.

You can use the JavaScriptSerializer class:

using System.Web.Script.Serialization;
var json = new JavaScriptSerializer().Serialize(obj);

Then you can return the object from webapi.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM