Visual Studio throws an error of something like “the t-type paramater can’t be derived”.
Can anyone tell me the type i need, or maybe show me an example of how to call it?
Okay, in order to do this, you need to be using System.Net, System.Net.Http, and I am also using Newtonsoft’s Json.NET library for the serializing and deserializing. That said, When you create a new HttpClient like so (it should be noted that this needs to be inside an async method:
<pre><code>
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add(“X-Mashape-Key”, “(your API key goes in here)”);
HttpResponseMessage response = await client.GetAsync("(the API url you want to get data from goes here)");
if (response.IsSuccessStatusCode)
{
string json = await response.Content.ReadAsStringAsync();
}
</code></pre>
It should also be noted that the Cardback is a class that i modeled after the data that comes back when you check the Test Endpoint in the documentation for the API. Makes things easier.
Okay, in order to do this, you need to be using System.Net, System.Net.Http, and I am also using Newtonsoft’s Json.NET library for the serializing and deserializing. That said, When you create a new HttpClient like so (it should be noted that this needs to be inside an async method:
<pre><code>
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add(“X-Mashape-Key”, “(your API key goes in here)”);
HttpResponseMessage response = await client.GetAsync("(the API url you want to get data from goes here)");
if (response.IsSuccessStatusCode)
{
string json = await response.Content.ReadAsStringAsync();
}
</code></pre>
It should also be noted that the Cardback is a class that i modeled after the data that comes back when you check the Test Endpoint in the documentation for the API. Makes things easier.
I got it to work in PowerShell, C# isn’t a far throw from there. Here is my code.
<code>
headers=New−Object"System.Collections.Generic.Dictionary[[String],[String]]"headers.Add(“X-Mashape-Key”, ‘PI3zxNvdI0mshHiytg14V58EhqRfp1COiS1jsn5Allwx0sioJm’)
$cards = Invoke-RestMethod -Uri https://omgvamp-hearthstone-v1.p.mashape.com/cards -Headers $headers
</code>