I am working on a C# backend with an HttpGet method that is expecting a dictionary as request parameters.
public async Task<IActionResult> Search([BindRequired, FromQuery] IDictionary<string, object> pairs)
Currently, my frontend is built in Angular 8. When the backend expects a dictionary like this, what should I pass in the Angular service class get method? Should it be a Query String or something else?
Right now, I am passing a query string in this manner:
search(parameters: any): Observable<any> {
var queryString = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&');
return this.httpClient.get(environment.host + environment.search + queryString);
}
However, this approach is not working as expected. Even though values are being passed from the frontend, when I debug and check, the backend request parameter values are showing up as null.
Thank you for your help!