Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 06, 2012 06:29 PM by sequeiradenzil
Member
106 Points
173 Posts
Mar 06, 2012 02:23 PM|LINK
I am using WCF Rest Service which has one method which takes List class as a paramter
and when i am passing list in json format to the method it gives 0 count while looping
below is my code of JSON
var profile = { "ARLog": [{ "UserId": "98EE86A0-E673-4B7B-85EA-00620135E3F4", "RequestTime": "/Date(628318530718)/", "SectionName": "Pts"}] } var inputdata = JSON.stringify(profile);
BELOW IS MY C# CODE
[OperationContract] [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedResponse, UriTemplate = "UpdateArResponse")] //[WebInvoke(Method = "POST", UriTemplate = "GetArResponse")] DateTime UpdateARLog(List<ARLog> parameters); public DateTime UpdateARLog(List<ARLog> parameters) // Here the parameter count is 0 { return DateTime.Today; }
All-Star
78956 Points
13402 Posts
MVP
Mar 06, 2012 02:27 PM|LINK
Check this article though not for WCF but it explains how to pass List to Webmethods
http://www.aspsnippets.com/Articles/Send-and-receive-JavaScript-Array-to-Web-Service-Web-Method-using-ASP.Net-AJAX.aspx
Mar 06, 2012 02:34 PM|LINK
Thanks for your reply but this is not helping me out. As mine is JSON and also i have appended same string like u have done still not working. Any help on JSON and REST WCF will be appreciated
24 Points
11 Posts
Nov 06, 2012 06:29 PM|LINK
Have a look at the following link ... I'm Sure it's gonna help
http://stackoverflow.com/questions/4247152/is-there-a-way-to-pass-a-list-of-json-objects-from-js-to-c
mmknitin
Member
106 Points
173 Posts
Passing Json List as parameter to WCF Rest Service
Mar 06, 2012 02:23 PM|LINK
I am using WCF Rest Service which has one method which takes List class as a paramter
and when i am passing list in json format to the method it gives 0 count while looping
below is my code of JSON
var profile = { "ARLog": [{ "UserId": "98EE86A0-E673-4B7B-85EA-00620135E3F4", "RequestTime": "/Date(628318530718)/", "SectionName": "Pts"}] } var inputdata = JSON.stringify(profile);
BELOW IS MY C# CODE
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: Passing Json List as parameter to WCF Rest Service
Mar 06, 2012 02:27 PM|LINK
Check this article though not for WCF but it explains how to pass List to Webmethods
http://www.aspsnippets.com/Articles/Send-and-receive-JavaScript-Array-to-Web-Service-Web-Method-using-ASP.Net-AJAX.aspx
Contact me
mmknitin
Member
106 Points
173 Posts
Re: Passing Json List as parameter to WCF Rest Service
Mar 06, 2012 02:34 PM|LINK
Thanks for your reply but this is not helping me out. As mine is JSON and also i have appended same string like u have done still not working. Any help on JSON and REST WCF will be appreciated
sequeiradenz...
Member
24 Points
11 Posts
Re: Passing Json List as parameter to WCF Rest Service
Nov 06, 2012 06:29 PM|LINK
Have a look at the following link ... I'm Sure it's gonna help
http://stackoverflow.com/questions/4247152/is-there-a-way-to-pass-a-list-of-json-objects-from-js-to-c