简体   繁体   中英

Webapi Multipart formdata to accept Images and JSON data

I tried to implement Webapi Action method which need to take Multipart formdata (Images and JSON Complex data). But the Json data which I am sending is coming as part of Formdata key value pairs instead of JSON and i couldn't parse it as a object.

I tried Advanced Rest client to test my API and below is sample request.

在ARC中索取样品

Is there a way, to make the API Controller to accept both files and Complex JSON object in a single action method.

Yes, You can. For that you have to convert file into Base 64 String. And than after add that string object to your model. so that you can get your data and file in base 64 format to your controller. and for that you don't need multipart/form-data.

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