I am new to visual studio. Currently I am using RestSharp to access an api that returns data in JSON format. My question is, how can I loop through the returned data and assign the values to variables that I can then display on my view.
I have set up the connection to the API and I can dump the returned value to an asp:literal.
Here is the code that handles that.
private void GetApiDataViaRestSharp()
{
var client = new RestClient
{
Authenticator = new HttpBasicAuthenticator(USERNAME, PASSWORD),
BaseUrl = API_ENDPOINT
};
var request = new RestRequest(Method.GET)
{
Resource = "Contact/{ContactId}"
};
request.AddUrlSegment("ContactId", CONTACT_TO_LOOKUP);
var response = client.Execute(request);
var contentBody = response.Content;
lit1.Text = contentBody;
}
Where do I go next?