I am trying to make a small application to get results of GitHub API to a text file.First I am trying to get data to the console.I tried many ways as well referred many documents but I couldn't find a way to fix this issues .
https://api.github.com/users/user?client_id=8763c42f48201b31115f&client_secret=4708b9aea8e35878b9748a016198b81de24352a4 Request forbidden by administrative rules. Please make sure your request has a User-Agent header (http://developer.github.com/v3/#user-agent-required). Check https://developer.github.com for other possible causes
This is the sample code I used.Can any one help me to fix the issue about the User-Agent header
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
GetGameData().Wait();
}
public static async Task<string> GetGameData()
{
var url = "https://api.github.com/users/user?client_id=8763c42f48201b31115f&client_secret=4708b9aea8e35878b9748a016198b81de24352a4";
using (HttpClient client = new HttpClient())
{
client.BaseAddress = new Uri(url);
Console.WriteLine(client.BaseAddress);
HttpResponseMessage response = await client.GetAsync(url);
string strResult = await response.Content.ReadAsStringAsync();
Console.WriteLine(strResult);
return strResult;
}
}
}
}