I am currently trying to get a correct VB.NET (or C#) code fragment for doing a LOGIN on astrometry.net. The procedure is described here: https://nova.astrometry.net/api_help and https://astrometry.net/doc/net/api.html
- I tried a lot of things, but the best I get is {"status": "error", "errormessage": "no json"}
- If I press the button on the web page with a wrong API key the site response is: {"status": "error", "errormessage": "bad apikey"}. Getting this in my code would already be enough.
This is my current fragment:
Dim LoginURL As String = "http://nova.astrometry.net/api/login"
Dim Enc As System.Text.Encoding = System.Text.Encoding.UTF8
Dim MediaType As String = "application/json"
Dim JSONContent As String = "{""apikey"": """ & APIKey & """}"
Dim C2String As New System.Net.Http.StringContent(JSONContent , Enc, MediaType)
'Run the query
Dim MyClient As New System.Net.Http.HttpClient
Dim F As System.Net.Http.HttpResponseMessage = Await MyClient.PostAsync(LoginURL, C2String)
Dim Code As String = Await F.Content.ReadAsStringAsync()
I think I miss some parameter to indicate that the query is in JSON format, but I have no idea where.
Any hints?
Best regards Martin