Hi,I am having trouble reading the JSON return from a call to the REST api to deleteFeatures:http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Delete_Features/02r3000000w4000000/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 vb.netFor the call to get a token... I have a class structure like this
<DataContract()>
Public Class tokenResponse
<DataMember()>
Public Property token As String
<DataMember()>
Public Property expires As Long
<DataMember()>
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 = "https://www.arcgis.com/sharing/generateToken?f=json&username=username&password=password&referer=www.cityofpsl.com"
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:http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Delete_Features/02r3000000w4000000/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
<DataContract()>
Public Class errorResults
<DataMember()>
Public Property code As String
<DataMember()>
Public Property desc As String
End Class
<DataContract()>
Public Class deleteRecord
<DataMember()>
Public Property objectId As Integer
<DataMember()>
Public Property globalId As String
<DataMember()>
Public Property success As Boolean
<DataMember()>
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 = "https://services1.arcgis.com/YdUP5V6WwzeG8T8r/ArcGIS/rest/services/SidewalkInspection/FeatureServer/0/deleteFeatures?"
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 = NothingobjectId = nothingsuccess = FalseEven though the feature is deleted. Any assistance in reading the JSON would be helpful.