asp.net web api - How to receive multiple complex objects using HTTp POST method in WebAp -
asp.net web api - How to receive multiple complex objects using HTTp POST method in WebAp -
i want phone call webapi method,this how webapi method looks like:
[httppost] [route("postmyservice/updatedby/{updatedbyid}/myobjname")] public void postterminalservice([frombody] list<sometype> lstsomeobj, myclass myobj, int updatedbyid) { //do }
this how client looks like:
int loggedinuserid=1; list<sometype> lits = new list<sometype>(); myclass myobj=new myclass(); var url = "api/xyz/postmyservice/updatedby/" + loggedinuserid + "/myobjname/" + myobj; httpresponsemessage response = client1.postasjsonasync(url, lits).result;
but error/exception getting is: http error 404.0 - not found causes: •the directory or file specified not exist on web server. •the url contains typographical error. •a custom filter or module, such urlscan, restricts access file.
any thought how resolve this?i kind of hitting wall on this.
thanks in advance.
you have "api/xyz/" prefixed in client code, don't see on server code. predict have in server configuration if not see issues.
you can have 1 object [frombody] tag in webapi, it's not clear how trying pass myclass
object.
only simple objects, ints , strings, can passed in uri string myclass
object not transferred correctly.
i recommend removing myclass
object or creating larger object encapsulates list<sometype> and
myclass` , pass in body of request [frombody] decoration.
here's more info on topic
asp.net-web-api http-post
Comments
Post a Comment