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(string url,
	object data,
	string contentType,
	string verb)

Return Value

string of HTTP response

Parameters

url
The url to access

data
The data to send. String data is sent as is all other data is JSON encoded.

contentType
Optional Content type for the request

verb
The HTTP Verb to use (GET,POST,PUT,DELETE etc.)

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