parse data sent by webapi. is IEnumerable a good choice?
By : stevemcc101
Date : March 29 2020, 07:55 AM
should help you out It's easy for you to deserialize back using Json.Net, in your case: code :
var json = "[\"value1\",\"value2\"]";
var values = JsonConvert.DeserializeObject<string[]>(json);
|
Passing IEnumerable parameter to WebAPI
By : Alfie Holden
Date : March 29 2020, 07:55 AM
I hope this helps . I'm getting started with WebAPI and for the most part all is going well. I'm running into a problem with one particular function. This one differs from the other because it's only parameter is of type IEnumerable. code :
contentType: 'application/json, charset=utf-8',
contentType: 'application/json; charset=utf-8',
public void Post([FromUri] IEnumerable<int> values)
public void Post(IEnumerable<int> values)
newArray = [ 1, 2, 3 ]
|
How do you Serialize an IEnumerable of a derived class in .net WebApi
By : Madhan MJ
Date : March 29 2020, 07:55 AM
it should still fix some issue I am using the .net WebApi to create a web service and am having issues serializing a class to XML when one of the properties is an IEnumerable of a derived class. I have tried adding the knownType bet get an error of: , Can you try modifying your 'orderDetailBase' class like below: code :
[DataContract]
[KnownType(typeof(onlineOrderDetail))]
[KnownType(typeof(inStoreOrderDetail))]
public class orderDetailBase
{
[DataMember]
public int sequence { get; set; }
|
Passing IEnumerable<int> to a WebApi action
By : user3633179
Date : March 29 2020, 07:55 AM
this one helps. I have this controller action: , If you have the controller action as code :
public IHttpActionResult GetMany([FromUri] int[] ids)
?ids=1&ids=2&ids=3...
|
Return json representations of data from WebAPI without strongly-typed IEnumerable
By : Hoàng Trọng Hiếu
Date : March 29 2020, 07:55 AM
I wish this helpful for you Web API handles serialization for you, so you do not need to call JsonConvert.SerializeObject. That is why you are getting an escaped string as your output value. Just pass the datatable directly to CreateResponse. Web API will turn it into JSON or XML for you depending on what was sent in the Accept header of the request. (It uses Json.Net under the covers.) code :
return Request.CreateResponse(HttpStatusCode.OK, dt);
|