HttpClientUtils.DownloadStringAsync

Runs an Http request and returns success results as a string or null on failure or non-200/300 requests.

Failed requests return null and set the settings.ErrorMessage property but you can can access the settings.Response or use the settings.GetResponseStringAsync() method or friends to retrieve content despite the error.

public static Task<String> DownloadStringAsync(HttpClientRequestSettings settings)

Return Value

string of HTTP response

Parameters

settings
Pass HTTP request configuration parameters object to set the URL, Verb, Headers, content and more

Remarks

By default this method does not throw on errors or error status codes, but returns null and an error message. For error requests you can check settings.HasResponseContent and then either directly access settings.Response, or use settings.GetResponseStringAsync() or friends to retrieve error content.

If you want the method to throw exceptions on errors an > 400 status codes, use settings.ThrowExceptions = true.

Overloads:


See also:

Class HttpClientUtils

© West Wind Technologies, 1996-2024 • Updated: 06/29/24
Comment or report problem with topic