Integrating GraphQL with c#

I have the following code but when executed it fails on " var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();"

I have run the query in the playground with my apikey and it works. When I run it here I get a 500 error with no details.

var q2 = new GraphQLRequest
{
Query = @"
query {
boards (limit:3) {
id
name
items {
id
name
column_values {
id
text
}
}
}
}"
};

            var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.monday.com/v2/");
            httpWebRequest.ContentType = "application/json; charset=UTF-8";
            httpWebRequest.Method = "POST";
            httpWebRequest.Headers.Add("Authorization", apiKey);

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                streamWriter.Write(q2.Query);
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
            }

Hey Aaron, did you manage to solve this? Sorry for the late response.

Have you been able to make any requests using this code snippet? For example, can you make this simple query successfully: { me { id } } ?

I’d start there and see if you can get that to work. I suspect the issue is either with how your program is constructing the HTTP request body, or how it’s formatting the line breaks.