0

I have an API where I consume a Json file from. The function I have written is

Public Function getData(ByVal _token As String, ByVal _identifier As String) As String
    Dim client = New RestClient(_baseURI)
    Dim request = New RestRequest("/datasources/{identifier}/data", Method.GET)
    request.AddUrlSegment("identifier", _identifier)
    request.AddHeader("Authorization", "Basic " + _token)
    Dim jstr = client.Execute(request).Content
    Dim allDATA As List(Of GeneralInfo) = JsonConvert.DeserializeObject(Of List(Of GeneralInfo))(jstr)

    Return 0
End Function

This works perfectly well. I can save the string into a file. But I also need a json file and I just do not know how to accomplish this.

Based on this solution I tried

request.OnBeforeDeserialization = Function(resp)
                                      resp.ContentType = "appliction/json"
                                  End Function
Dim queryResult = client.Execute(request)
Console.WriteLine(queryResult.Content)

but without any result. Nothing will be written into the console. Any idea how I can get the json file? I am using

Imports Newtonsoft.Json
Imports RestSharp
djv
  • 15,168
  • 7
  • 48
  • 72
ruedi
  • 5,365
  • 15
  • 52
  • 88

0 Answers0