When calling a web api where there are null values, the return object drops the property. I have read many articles on-line that talk about the problem being fixed with the new release but it did not work for me. After looking around and testing a few options I found a very easy fix. The below code is a sample code from a real application.
For Each t In NewsData NewsItemList.Add(New NewsList(Date.ToString("MM/dd/yyyy"), t._id, t.Caption, _ t.Article, t.PublishPeriod, t.isActive)) Next ..... ..... ..... Public Class NewsList Public Property DatePosted As Date Public Property _id As Integer Public Property Caption As String Public Property Article As String Public Property PublishPeriod As String <Required()> Public Property isActive As Boolean Public Sub New(ByVal DatePosted As Date, ByVal _id As Integer, ByVal Caption As String, _ ByVal Article As String, ByVal PublishPeriod As String, ByVal isActive As Boolean) Me.DatePosted = DatePosted Me._id = _id Me.Caption = Caption Me.Article = Article Me.PublishPeriod = PublishPeriod Me.isActive = isActive End Sub
The important part of these lines of code is adding a ‘Required()’ attribute. (Line 14)
Looking for quality web hosting? Look no further than Arvixe Web Hosting!