Help reading JSON return from deleteFeatures

Discussion created by mkohlerpsl on Feb 18, 2014
Latest reply on Feb 19, 2014 by mkohlerpsl
I am having trouble reading the JSON return from a call to the REST api to deleteFeatures:

I am new to using JSON and this probably isn't the right place to ask, but does anyone have any clues as to how to structure the class used to deserialize the JSON reponse from this function.

I can call it and verify that it is working and the features are being deleted. but that doesn't help the code to determine if something went wrong.

I am writing an add-in for desktop using
For the call to get a token... I have a class structure like this
    Public Class tokenResponse
        Public Property token As String
        Public Property expires As Long
        Public Property ssl As Boolean

        Public Sub New(ByVal tkn As String, ByVal expire As Long, ByVal s As Boolean)
            token = tkn
            expires = expire
            ssl = s
        End Sub
    End Class

Then I call the web request and deserialize as shown below.

        Dim tokenURL As String = ""
        Dim tokenRequest As HttpWebRequest = CType(System.Net.WebRequest.Create(tokenURL), HttpWebRequest)
        Dim tokenResponse As HttpWebResponse = CType(tokenRequest.GetResponse(), HttpWebResponse)
        Dim tokenSerializer As New DataContractJsonSerializer(GetType(tokenResponse))
        Dim tknRsp As tokenResponse = TryCast(tokenSerializer.ReadObject(tokenResponse.GetResponseStream), tokenResponse)

So I thought it would be the same for reading the deleteFeatures response documented in the REST API here:

At the bottom of that page is the response format given back from the api.

So I used the following data contract or class below
    Public Class errorResults
        Public Property code As String
        Public Property desc As String
    End Class
    Public Class deleteRecord
        Public Property objectId As Integer
        Public Property globalId As String
        Public Property success As Boolean
        Public Property errList As List(Of errorResults)
    End Class

    Public Class delData
        Public Property code As String
        Public Property description As String

    End Class

And called the web request like this:

        Dim delURL As String = ""
        delURL += "f=json"
        delURL += "&token=" + tknRsp.token
        delURL += "&objectIds=2626"                        'the object id of the feature I want deleted goes here

        Dim delRequest As HttpWebRequest = CType(System.Net.WebRequest.Create(delURL), HttpWebRequest)
        delRequest.Method = "POST"
        delRequest.ContentLength = Long.Parse(delURL.Length)
        Dim delResponse As HttpWebResponse = CType(delRequest.GetResponse(), HttpWebResponse)

        Dim delSerializer As New DataContractJsonSerializer(GetType(deleteRecord))
        Dim delRsp As deleteRecord = TryCast(delSerializer.ReadObject(delResponse.GetResponseStream)(), deleteRecord)

But the program runs and the delRsp class shows
errList = Nothing
globalId = Nothing
objectId = nothing
success = False

Even though the feature is deleted. Any assistance in reading the JSON would be helpful.