I know you say that we can receive the data in a json format, but I am unsure how to do this. I believe I changed the accept header to “application/json”, but when run, none of the data ever appears; the forecast object is null. Could you give a sample c# call that returns the data in a json format?
please try using the following function to request the api like this:
string output = GET;
public static string GET(string url, string output_type)
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Accept = output_type;
WebResponse response = request.GetResponse();
using (Stream responseStream = response.GetResponseStream())
StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
catch (WebException ex)
WebResponse errorResponse = ex.Response;
using (Stream responseStream = errorResponse.GetResponseStream())
StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
String errorText = reader.ReadToEnd();
got the function from here:
Once I have the output string, how do I actually separate it into classes? I’ve defined all of the classes that the json string will contain, but I don’t know how to actually create an object of the type that will be produced.
This link that might be helpful for you:
It provides a good example of what you want to accomplish.