How to use the Github API in ASP.net

Asked

Viewed 1,040 times

3

Good afternoon.

I would like to know how to work with github API in ASP.NET. I’ve never worked with Apis before.

P.S. I cannot use octokit

Can someone help me? Thank you

  • 3

    Why can’t you use Octokit? It’s the main API.

  • It’s a selection so I can’t use Octokit. I should only use the Open Api (REST)

  • What is a "selection"? We’re talking about this API?

  • No, sorry I confused.. I can’t use it because I’m participating in a developer selection.

  • You are participating in a selection process. I think I went through the same as yours! Haha - I will see if I answer by giving only the path of stones...

1 answer

2

DRT;

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

A Little Bit of Background

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

  • GET - catch content of the API
  • POST - introduce content in the API
  • PUT - upgrade content in the API
  • DELETE - remove content of the API

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’m not gonna give you the answer. Since you’re participating in a selection process (and other people fall for that answer in the same situation), that wouldn’t 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 (like you do from your browser to access any web page). So you can use the class Httprequest to consume the API. By changing the URL and request 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 string, for a simpler data exchange. To turn this JSON into something you can use, you can use the library JSON.NET (ancient Newtonsoft.Json), to turn it into a normal C# object.

That’s basically it! Then you’ll have everything you need. Research on these guys who have a lot of tutorial over the internet. In case you don’t understand anything, just say the word.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.