How to use the GitHub API in ASP.net

3

Good afternoon.

I would like to know how to work with the gitHub API in ASP.NET. I've never worked with APIs before.

PS. I can not use octokit

Can anyone help me? Thanks

    
asked by anonymous 26.11.2015 / 20:33

1 answer

2

TLDR;

Use normal HTTP requests to access the API by reading the return JSON data.

A Little Background

The GitHub API is a RESTful API, which basically means that your data is accessible by common HTTP requests, without using extra protocols to read them (like SOAP ). A REST API is based on the correct use of the HTTP protocol, using its methods for what was actually created:

  • GET - catch API content
  • POST - enter content in the API
  • PUT - update content in the API
  • DELETE - remove API content

The REST specification also introduced the term resource, which is nothing more than what the API exposes (users, repos, etc) and the best use of URIs (Uniform Resource Identifier), to identify specific resources (URLs are URIs).

The Answer

I will not give you the answer. Since you are participating in a selection process (and other people fall into that response in the same situation), that would not be fair; I'll just explain how it works, what to do, but no code.

As I said, REST APIs can be consumed through normal HTTP requests (the kind you use to navigate to any webpage). Therefore, you can use the HttpRequest class. to consume the API. By changing the request URL and method you can do everything you need to extract data from the API.

Once you get the data, you'll get a string, that's a JSON. It is a way of representing data (an instance of a class with all its properties, for example) by means of a string, for a simpler data exchange. To make this JSON something you can use, you can use the JSON.NET library (old Newtonsoft.Json ) to do with which it will turn a normal C # object.

That's basically it! Then you will have everything you need. Search about these guys who have a lot of tutorial over the internet. If you do not understand something, just talk.

    
01.12.2015 / 20:36