c# - REST post request with optional file upload -


while creating wcf rest service, receiving data in json , able save in database. need give option upload file(optional, image or video) same service. tried sending byte array giving bad request error possibly because of serialization of such long array. read upload large files need use stream. how while sending other parameters? creating service receive data mobile device. here service interface

[webinvoke(uritemplate = "savefbpost",      method = "post",      bodystyle = webmessagebodystyle.wrapped,     requestformat = webmessageformat.json,      responseformat = webmessageformat.json)] [operationcontract] void savefacebookpost(fbpostdata fbpostdata); 

public class fbpostdata:

[datamember] public string scheduledate { get; set; }  [datamember] public string userid { get; set; }  [datamember] public string groupid { get; set; }   [datamember] public string posttext { get; set; }  [datamember] public byte[] file { get; set; }  [datamember] public string filetype { get; set; }  [datamember] public string accesstoken { get; set; } 

i start increasing maxbuffersize , maxarraylength particular binding in web.config, , see if resolves issue.

you should able pull more specifics on error well, can see why getting 400 error.

this blog article useful me in past - there links @ bottom well.

also take @ stream class. not sure mean "sending other parameters" - if can clarify this, can give more direction on that.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -