0

I'm trying to create a winforms app that enables the user to input a LoL Username and on pressing the button it generates the SummonerV4 API info from Riot. I'm having trouble figuring this out. Image of form.

This is what the code for the actual form is looking like currently. I get thrown exceptions because RiotAPI is Null. What would I need to add to get this running?

using System;
using System.Net;
using System.Text;
using System.Net.Http;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using Newtonsoft.Json;
using MingweiSamuel.Camille;
using System.Windows.Forms;

namespace RiotAPI_ESavage
{
public partial class Form1 : Form
{


    private void Form1_Load(object sender, EventArgs e)
    {
        this.PopulateLoLDataGridView();
    }

    public Form1()
    {
        InitializeComponent();
    }

    public object apiResponse { get; private set; }

    private async void GetAPIData_Click(object sender, EventArgs e)
    {
        var response = await SummonerV4.GetALL();
        apiResponse = response;//.text  = response;
        this.PopulateLoLDataGridView();
    }

    private void PopulateLoLDataGridView()
    {
        string apiUrl = "https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/";
        object input = new
        {
            Name = textBox1.Text.Trim(),
        };
        string inputJson =

        RiotAPI.Headers["Content-type"] = "application/json";
        RiotAPI.Encoding = Encoding.UTF8;
        string json = RiotAPI.UploadString(apiUrl + "/GetSummonerInfo", inputJson);

        dataGridView1.DataSource = dataGridView1;
    }

    private void textBox1_TextChanged(object sender, EventArgs e)
    {

    }

    private WebClient RiotAPI;




    private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {

    }
}

}

stuartd
  • 70,509
  • 14
  • 132
  • 163
ItsE
  • 1
  • 2

0 Answers0