Again, this is HTTP, not objects and methods so you're thinking about it at the wrong level. There's one body to the HTTP request and that's where you put inputs (other than query string and route inputs, but I suspect you're not looking for those since
they're simple types). So that one body can contain a JSON representation of data and that can contain arbitrary complex data.
muhamad_ahsa...
Member
3 Points
12 Posts
Multiple complex type parameters
Dec 23, 2012 11:50 AM|LINK
Hi guys!
I am learning Web API. One more question: Can we have api action(method) which has more than one comple type? e.g.
public string PostEmployee(Employee employee, Address address)
{ // method code
return "";
}
So, is the above scenario possible? If yes, then how to make a call to this method? And if no, then any good reasons and workarounds?
BrockAllen
All-Star
27512 Points
4895 Posts
MVP
Re: Multiple complex type parameters
Dec 23, 2012 07:31 PM|LINK
Again, this is HTTP, not objects and methods so you're thinking about it at the wrong level. There's one body to the HTTP request and that's where you put inputs (other than query string and route inputs, but I suspect you're not looking for those since they're simple types). So that one body can contain a JSON representation of data and that can contain arbitrary complex data.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
Srigopal
Member
7 Points
4 Posts
Re: Multiple complex type parameters
Dec 28, 2012 05:12 PM|LINK
Hi Muhamad,
As Allan said, use JSON or XML type. I suggest go for JSON so that you can extract your object once you receive eigther side.
Thanks,
Regards,
Srigopal