I've tried to have a look online for an answer to this and I'm not finding anything.
This method I have looks fine, and seems to follow the general flow of how async post calls work in c#.
private static async Task<HttpResponseMessage> GetGeocodingAsync(string URL, string JSONQuery)
{
using (HttpClient client = new HttpClient())
{
using (HttpResponseMessage r = await client.PostAsync(URL, new StringContent(JSONQuery, Encoding.UTF8, "application/json")))
{
return r;
}
}
}
public Task<HttpResponseMessage> GetGeocoding(string TTURL, string JSONQuery)
{
return GetGeocodingAsync(TTURL, JSONQuery);
}
When I check my syntax and in my IDE however when I run the application it gets as far as line 5 then the application just ends with a code 0 (exited with code 0 (0x0).).
I've done a lot of web research and can't find an answer for this. Am I missing something fundamental here?
I understand that I have to use an private static async
for the actual post part, then I can call this method from a non-static non-async method, and in my main class I can process the response that I get like this:
Task<HttpResponseMessage> x = TTConnect.GetGeocoding(TTConnect.GetTTConnectionURL(),JSONQuery);
I'm trying to send some data in JSON format using POST, check the response by parsing it, and pull down the response to the POST.
I'm using the TomTom Batch API
Any thoughts or suggestions would be welcome.