I have my class and a part of my code that use it on VB.NET
Public Class ResponseError
Public code As String = ""
Public message As String = ""
End Class
Public Class clsAPI
Public lastError As New ResponseError
Public Function addEntities(ByVal entities() As RequestAddEntity, ByVal a As clsCompany) As Boolean
Try
If Not isLogged() Then Throw New System.Exception("Error on login.")
client.BaseUrl = New System.Uri(_serverUrl)
Dim request = New RestRequest()
request.Resource = {url}
request.AddHeader("code", a.CompanyCode)
request.AddHeader("token", _token)
request.AddParameter("item", SimpleJson.SerializeObject(entities))
request.Method = Method.POST
Dim response As RestResponse = client.Execute(request)
If response.ResponseStatus = ResponseStatus.Error Then
lastError.code = response.ResponseStatus
lastError.message = response.ErrorMessage
Logger.Error("End addEntities() with error: " & lastError.message & " (" & lastError.code & ")")
Return False
End If
Dim json = SimpleJson.DeserializeObject(Of ResponseLogin)(response.Content)
If Not json.result Then
For Each error In json.errors
lastError = error
Logger.Error("End addEntities() with error: " & lastError.message & " (" & lastError.code & ")")
Return False
Next
End If
Logger.Trace("End addEntities()")
Return True
Catch ex As Exception
lastError.code = 0
lastError.message = ex.Message
Logger.Error("End addEntities() with exception: " & lastError.message & " (" & lastError.code & ")")
Return False
End Try
End Function
End Class
But sometimes I have this error on my log:
2020-02-03 16:48:13.2902|ERROR|clsAPI.addEntities|End addEntities() with exception: Invalid cast from 'System.String' to 'ETAgentI4U.ResponseError'. (0)
Do you know the meaning of it? How can I solve it?
Thanks :)