1
Answer

JSON RestClient 107

Geni Lou

Geni Lou

3y
1.3k
1

How can I make the body dynamically especially the type which is list? 

            var options = new RestClientOptions(baseUrl){
                ThrowOnAnyError = true,
                Timeout         = 1000
            };
            var client          = new RestClient(options);
            RestRequest request = new RestRequest("/authtoken", Method.Post);

            request.AddHeader("Content-Type", "application/json");

            var body = @"{" + "\n" +
            @"  ""clientId"": 1111," + "\n" +
            @"  ""clientPassword"": ""password""," + "\n" +
            @"  ""type"": [" + "\n" +
            @"    ""admin""," + "\n" +
            @"    ""sa""" + "\n" +
            @"  ]" + "\n" +
            @"}";

            request.AddJsonBody(body);
            var response = client.PostAsync<Authentication>(request);
            return response.Result.token;

Answers (1)