Hearthstone

FREE
By omgvamp | Updated 16 days ago | Entertainment
Popularity

9.7 / 10

Latency

2,225ms

Service Level

99%

Health Check

N/A

Back to All Discussions

Has anyone got this to work in c# or vb.net ?

Rapid account: Nippleguy
nippleguy
8 years ago

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?

Rapid account: The Kopp End
theKoppEnd Commented 7 years ago

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.

Rapid account: Wtreadway
Wtreadway Commented 7 years ago

I got it to work in PowerShell, C# isn’t a far throw from there. Here is my code.

<code>
headers=NewObject"System.Collections.Generic.Dictionary[[String],[String]]"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>

Join in the discussion - add comment below:

Login / Signup to post new comments