There are several ways to do this, including I do not know if the question does not fit as too broad.
Anyway, I'll show you how to make a request GET
using RestSharp because it makes the whole issue of requesting, serializing / deserializing the data, etc. very much easier.
You can install it via nuget with the
PM > Install-Package RestSharp
Request example GET
to http://fipeapi.appspot.com/api/1/carros/marcas.json
public class Program
{
public static void Main()
{
var client = new RestClient
{
BaseUrl = new Uri("http://fipeapi.appspot.com/")
};
var req = new RestRequest("api/1/{tipo}/marcas.json", Method.GET);
req.AddParameter("tipo", "carros", ParameterType.UrlSegment);
var response = client.Execute(req);
var contentResponse = JsonConvert.DeserializeObject<List<Marca>>(response.Content);
// ^ Nesta lista vão estar todas as marcas da resposta
}
}
public class Marca
{
public int Id { get; set; }
public string Key { get; set; }
public string Name { get; set; }
public string Fipe_Name { get; set; }
}
Code in GitHub for future reference
Note that Marca
is a type that you must create. response.Content
is the return in the original format ( JSON ) and contentResponse
will be a List<Marca>
, that is, the JSON original deserialized.