c# - How to Pass Dynamic Json Object (data) to wcf ResTful Services? -
so lets have json data set following though json data( model or structure) of data not static , change based on each call, how can pass generic json data set post method of wcf code?
{ "experience": 14746, "status": true, "name": "aaron", "uuid": "3123" }
i want use postman or soapui body?
public object postdata(string id, [frombody] jobject data) { //do data } public interface ipostservice { [operationcontract(name = "postdata")] [webinvoke(method = "post", uritemplate = "/postdata?id={id}&data={data}")] object postdata(string id,[frombody] jobject data); }
any appreciate it
when specify in uritemplate attribute variable data saying value become in query string, not in body, default http method of webinvokemethod attribute post.
public object postdata(string id, string data) { //do data } public interface ipostservice { [operationcontract(name = "postdata")] [webinvoke(uritemplate = "/postdata?id={id})] object postdata(string id, string data); }
then can use newtonsoft library parse string value in format json object dynamic properties. can use newtonsoft library nuget .
to learn, how parse dynamic objects newtonsoft, click here.
Comments
Post a Comment