There are several ways to do this, including I don’t know if the question fits as too wide.
Anyway, I’ll show you how to make a request GET
using the Restsharp because it greatly facilitates the whole question of making the requests, serializing/deserilizing the data, etc.
It is possible to install it via nuget, with the command
PM> Install-Package Restsharp
Request example GET
for 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 on Github for future reference
Realize that Marca
is a type that should be created by you. response.Content
is the return in the original format (JSON) and contentResponse
will be a List<Marca>
, i.e., the JSON original deserialized.
Welcome to SOPT. What have you tried? Add to question so that the answers have a solution foundation.
– user28595
So far I’ve made no attempt, because I don’t know where to leave...
– Stephen Willians
Well if you don’t know where to start the question gets too wide, the api uses JSON can start by giving a read on documentations and examples that manipulate this in the language you want C# in the case, look for example of persistence of mysql data with C# and arise a specific question put here.
– SneepS NinjA