Here is the raw trace output:
Exception thrown: 'System.Exception' in System.Private.CoreLib.dll
WinRT information: The certificate authority is invalid or incorrect
Exception thrown: 'System.Exception' in System.Net.Http.dll
WinRT information: The certificate authority is invalid or incorrect
Exception thrown: 'System.Exception' in System.Private.CoreLib.dll
WinRT information: The certificate authority is invalid or incorrect
Exception thrown: 'System.Exception' in System.Net.Http.dll
WinRT information: The certificate authority is invalid or incorrect
Exception thrown: 'System.Exception' in System.Private.CoreLib.dll
WinRT information: The certificate authority is invalid or incorrect
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
'GroceryList.UWP.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Program Files\WindowsApps\Microsoft.NET.CoreFramework.Debug.2.2_2.2.30316.1_x64__8wekyb3d8bbwe\System.Diagnostics.StackTrace.dll'.
Http Request Error: System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Exception: The text associated with this error code could not be found.
The certificate authority is invalid or incorrect
at System.Net.Http.HttpHandlerToFilter.SendAsync(HttpRequestMessage request, CancellationToken cancel)
at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.HttpClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at GroceryList.Services.SerpApi.QueryCorrect(String phrase)
Here is the method performing the query:
private static async Task<string> QueryCorrect(string phrase)
{
string newQueryString = null;
Debug.WriteLine("Phrase is: " + phrase);
var newSpellingBuilder = new UriBuilder
{
Scheme = "https",
Host = "serapi.com",
Path = "search.json",
Query = $"engine=walmart&query={phrase}&api_key={AppSettings.ApiKey2}"
};
var httpClientSpelling = new HttpClient();
var httpRequestSpelling = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = newSpellingBuilder.Uri
};
try
{
using var responseSpelling = await httpClientSpelling.SendAsync(httpRequestSpelling);
responseSpelling.EnsureSuccessStatusCode();
var result = await responseSpelling.Content.ReadAsStringAsync();
if (result == null) return null;
var obj = JObject.Parse(result);
var q1 = obj["search_information"] as JObject;
Debug.WriteLine($"spelling query returns: " + q1);
newQueryString = q1["Spelling_fix"]?.ToString();
}
catch (HttpRequestException e)
{
Debug.WriteLine("Http Request Error: " + e);
Crashes.TrackError(e);
}
return newQueryString;
}
Any ideas on this?
It works when I paste the URL into the search bar of the browser just fine.