'How to use a JSON GET with cshtml/Razor for a foreach button
Goodmorning,
I was wondering if someone can help me out with the following question.
I am building my first webpage in C#, over here I would like to use a GET from an external source. In Postman but also in PHP I am able to realize this with the all the fields I need.
In this case Postman has some default c# code (RestSharp) which is okay.
var client = new RestClient("URL");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer Token");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("username", "UiD");
request.AddParameter("password", "Pwd");
request.AddParameter("grant_type", "password");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
How can I call this and use 4 of the 13 keys and values of this request? I would like to use the Firstname, Middlename, Lastname and PersonalId. The rest is not needed for this page.
After this I need to use them in a foreach to show them in buttons.
On the internet I see a lot about models, views and other stuff I just only have these default
I do not have any example since I am not able to figure out how I can get this worked.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
