tifa
1
i try to send api call, But I get an error
this is my code
static async Task Main()
{
string query = @"query MyQuery {ethereum(network: bsc) {transfers(currency: {is: ""0x2170ed0880ac9a755fd29b2688956bd959f933f8""} success: true options: { desc:""amount"", offset: 0, limit: 3}) {receiver {uniq: address} amount} } }";
var data = new StringContent(query, Encoding.Default, "application/json");
var url = "https://graphql.bitquery.io";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-KEY", "***";
var response = await client.PostAsync(url, data);
var res = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(res);
}
and server risponce is
Hello, try something like this!
static async Task Main()
{
string query = @"query MyQuery {ethereum(network: bsc) {transfers(currency: {is: \"0x2170ed0880ac9a755fd29b2688956bd959f933f8"\} success: true options: { desc:\"amount"\, offset: 0, limit: 3}) {receiver {uniq: address} amount} } }";
var data = new StringContent(query, Encoding.Default, "application/json");
var url = "https://graphql.bitquery.io";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("API-KEY", "***");
var response = await client.PostAsync(url, data);
var res = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(res);
}
note that it is better to use double quotation marks
1 Like
tifa
3
Hi
The result is the same for ( "" ) and ( \" )
I have no knowledge in c# to help you deeply, but what I can assure you is that there is no error on the part of bitquery, the query works correctly
gaurav
5
We have launched “Code Snippet” So now you can get code for your query from IDE.