Best way to pass List in query string HttpClient.GetAsync()
I use HttpClient.GetAsync() method. I have a list of categories and want to pass it in query string. var categories = new List<int>() {1,2}; How can I pass List<int>/List<string> in query string? For example, https://example.com/api?categories=1,2 Of course, can use foreach and StringBuilder. But maybe there is a better way to do this? For example, work with .PostAsync() and json content very convenient: var categories = new List<int>() {1,2}; //init List var parametrs = new Dictionary<string, object>(); parametrs.Add("categories", categories); string jsonParams = JsonConvert.SerializeObject(p
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.