Skip to content

Commit 403bc36

Browse files
Update httpclient.md (#42030)
* Update httpclient.md Adding details about sending HTTP request using HttpClient on Android * Update docs/fundamentals/networking/http/httpclient.md --------- Co-authored-by: David Pine <[email protected]>
1 parent 2c4a421 commit 403bc36

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/fundamentals/networking/http/httpclient.md

+13
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ To make an HTTP request, you call any of the following APIs:
6262
> [!WARNING]
6363
> Making HTTP requests is considered network I/O-bound work. While there is a synchronous <xref:System.Net.Http.HttpClient.Send%2A?displayProperty=nameWithType> method, it is recommended to use the asynchronous APIs instead, unless you have good reason not to.
6464
65+
> [!NOTE]
66+
> While targeting Android devices (such as with .NET MAUI development), you must add `android:usesCleartextTraffic="true"` to `<application></application>` in _AndroidManifest.xml_. This enables clear-text traffic, such as HTTP requests, which is otherwise disabled by default due to Android security policies. Consider the following example XML settings:
67+
>
68+
> ```xml
69+
> <?xml version="1.0" encoding="utf-8"?>
70+
> <manifest xmlns:android="http://schemas.android.com/apk/res/android">
71+
> <application android:usesCleartextTraffic="true"></application>
72+
> <!-- omitted for brevity -->
73+
> </manifest>
74+
> ```
75+
>
76+
> For more information, see [Enable clear-text network traffic for the localhost domain](/dotnet/maui/data-cloud/local-web-services?view=net-maui-8.0#enable-clear-text-network-traffic-for-the-localhost-domain).
77+
6578
### HTTP content
6679
6780
The <xref:System.Net.Http.HttpContent> type is used to represent an HTTP entity body and corresponding content headers. For HTTP methods (or request methods) that require a body, `POST`, `PUT`, and `PATCH`, you use the <xref:System.Net.Http.HttpContent> class to specify the body of the request. Most examples show how to prepare the <xref:System.Net.Http.StringContent> subclass with a JSON payload, but other subclasses exist for different [content (MIME) types](https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/MIME_types).

0 commit comments

Comments
 (0)