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.
[code language=”vb”]
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
[/code]
The important part of these lines of code is adding a ‘Required()’ attribute. (Line 14)
[code language=”vb”]
<Required()>
[/code]
Looking for quality web hosting? Look no further than Arvixe Web Hosting!
The problem might be caused by having PHP magic quotes on.
Ensure this configuration is in your php.ini:
magic_quotes_gpc = Off