Main API interface:https://api.hamcq.cn/v1/logbook?from=gridtracker, includingfromThe parameters have a filtering mechanism, and can only be:gridtracker。
Parameters (application/json):
{
"key": "YOUR_API_KEY",
"adif":"ADIF_STRING",
"app":"YOUR_APPLICATION_NAME"
}
Only the "key" field is required. If you only fill in the "key," it's equivalent to testing whether the key is valid, and all parameters must be correctly filled in for successful log upload.
If the key is valid, the backend will return "Pass", and regardless of whether the uploaded ADIF file is valid or not, it will always return "Pass". However, this will not be logged. If another situation occurs, it might provide a JSON response explaining the reason, for example:
// At this time, the HTTP status code is 406
{"code":406,"status":false,"message":"Invalid"}
Example:
// See https://github.com/SydneyOwl/cloudlog-helper for more
public class HamCQAPIExample
{
public static async Task<string> TestHamCQConnectionAsync(string apiKey)
{
return await UploadQSOToHamCQAsync(apiKey, null);
}
public static async Task<string> UploadQSOToHamCQAsync(string apikey, string? adif)
{
try
{
var reqJson = new JObject { { "key", apikey } };
if (adif is not null)
{
reqJson.Add("adif", adif);
reqJson.Add("app", DefaultConfigs.DefaultApplicationName);
}
var result = await DefaultConfigs.HamCQQsoUploadEndpoint
.AllowHttpStatus(406)
WithHeader("User-Agent", DefaultConfigs.DefaultHTTPUserAgent)
.WithHeader("Content-Type", "application/json")
.WithTimeout(TimeSpan.FromSeconds(DefaultConfigs.DefaultRequestTimeout))
.PostStringAsync(reqJson.ToString());
var responseText = await result.GetStringAsync();
var code = result.StatusCode;
if (responseText == "Pass") return string.Empty;
var res = JsonConvert.DeserializeObject<JObject>(responseText);
if (res is null) return $"HamCQ Error: {TranslationHelper.GetString("invalidapikey")}({responseText})";
return $"HamCQ Error: {TranslationHelper.GetString("invalidapikey")} ({res["message"]})";
}
catch (Exception e)
{
return e.Message;
}
}
}