Guest User

Untitled

a guest
Dec 13th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. {
  2. "message": "System.InvalidCastException: Conversion from type 'JObject' to type 'String' is not valid.rn at Microsoft.VisualBasic.CompilerServices.Conversions.ToString(Object Value)rn at WebApplication7.Controllers.SubjectsController.getSubjects(Object data) in C:\Users\Junaida\documents\visual studio 2015\Projects\WebApplication7\WebApplication7\Controllers\SubjectsController.vb:line 30"
  3.  
  4. <HttpPost>
  5. Function getSubjects(<FromBody> ByVal data As Object) As IHttpActionResult
  6. Try
  7.  
  8. Using entities As IAPD_DBEntities = New IAPD_DBEntities()
  9.  
  10.  
  11. Dim year, type, id As String
  12. Dim dictionary = JsonConvert.DeserializeObject(data) 'As Dictionary(Of String, String)
  13.  
  14.  
  15. Dim startno As Integer = 0
  16. If year = 1 Then
  17. startno = 0
  18. ElseIf year = 2 And type = 1 Then
  19. startno = 366
  20. ElseIf year = 2 And type = 3 Then
  21. startno = 52
  22. ElseIf year = 2 And type = 2 Then
  23. startno = 13
  24. End If
  25.  
  26.  
  27.  
  28. dictionary.Add("id", id)
  29. dictionary.Add("Type", type)
  30. dictionary.Add("Year", year)
  31.  
  32.  
  33. Return Ok(entities.SP_Messages_GetinfoArchive_ByID(startno, id, type, year).ToList)
  34. End Using
  35. Catch e As Exception
  36. Return BadRequest(e.ToString)
  37. End Try
  38. End Function
  39.  
  40.  
  41. End Class
Add Comment
Please, Sign In to add comment