nanoFramework.System.Net.Http 1.5.110

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package nanoFramework.System.Net.Http --version 1.5.110
                    
NuGet\Install-Package nanoFramework.System.Net.Http -Version 1.5.110
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nanoFramework.System.Net.Http" Version="1.5.110" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.System.Net.Http" Version="1.5.110" />
                    
Directory.Packages.props
<PackageReference Include="nanoFramework.System.Net.Http" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add nanoFramework.System.Net.Http --version 1.5.110
                    
#r "nuget: nanoFramework.System.Net.Http, 1.5.110"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package nanoFramework.System.Net.Http@1.5.110
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=nanoFramework.System.Net.Http&version=1.5.110
                    
Install as a Cake Addin
#tool nuget:?package=nanoFramework.System.Net.Http&version=1.5.110
                    
Install as a Cake Tool

Quality Gate Status Reliability Rating License NuGet #yourfirstpr Discord

nanoFramework logo


Welcome to the .NET nanoFramework System.Net.Http Library repository

Build status

Component Build Status NuGet Package
System.Net.Http Build Status NuGet
System.Net.Http.Client Build Status NuGet
System.Net.Http.Server Build Status NuGet

Usage examples

The API, classes and namespaces in this library follow, as close as possible, the .NET ones. Exceptions are the lack of async calls, generics and the Task, async/await model. The names reflect that by dropping the Async suffix and not returning Task and the lack of the overloaded methods with CancelationToken parameters.

Also worth mentioning is the need to pass the CA root certificate to HttpClient in order to be able to validate the server certificate.

HttpClient calling REST services

HttpClient makes it very easy to connect and consume REST services. In order to use it, one has to create the object and them perform the calls. Note that HttpClient is meant to be reused throughout the application lifecycle. There is no need to create a new instance every time a call has to be performed. Like this:

static readonly HttpClient _httpClient = new HttpClient();

To pass the CA root certificate allowing to validate the secure server certificate. The CA root cert can also come from a binary file or text file from a resource.

_httpClient.HttpsAuthentCert = new X509Certificate(
@"-----BEGIN CERTIFICATE-----
MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl
MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp
U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQw
NjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBoMQswCQYDVQQGEwJVUzElMCMGA1UE
ChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZp
ZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqGSIb3
DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf
8MOh2tTYbitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN
+lq2cwQlZut3f+dZxkqZJRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0
X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVmepsZGD3/cVE8MC5fvj13c7JdBmzDI1aa
K4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSNF4Azbl5KXZnJHoe0nRrA
1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HFMIHCMB0G
A1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fR
zt0fhvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0
YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBD
bGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8w
DQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGsafPzWdqbAYcaT1epoXkJKtv3
L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLMPUxA2IGvd56D
eruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl
xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp
VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY
WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=
-----END CERTIFICATE-----");

It's possible to add HTTP headers that will be sent along with each request.

_httpClient.DefaultRequestHeaders.Add("x-ms-blob-type", "BlockBlob");

Perform a HTTP GET request

Here's a example of a HTTP request to read some content as a string:

HttpResponseMessage response = _httpClient.Get("https://httpbin.org/get");
response.EnsureSuccessStatusCode();
var responseBody = response.Content.ReadAsString();

The above call would return something similar to the following, which can be output in Visual Studio by calling Debug.WriteLine(responseBody):

{
  "args": {}, 
  "headers": {
    "Host": "httpbin.org", 
    "X-Amzn-Trace-Id": "Root=1-6214aad3-38e5f8357bdf90530300eb5f", 
    "X-Ms-Blob-Type": "BlockBlob"
  }, 
  "origin": "5.249.47.208", 
  "url": "https://httpbin.org/get"
}

Note the call to response.EnsureSuccessStatusCode();. This will throw an HttpRequestException in case the status code from the HTTP request is not a successful one.

Perform a HTTP POST request

Follows an example of a HTTP request performing POST request to send some json content to an endpoint.

var content = new StringContent("{\"someProperty\":\"someValue\"}", Encoding.UTF8, "application/json");
var result = _httpClient.Post("https://httpbin.org/anything", content);
result.EnsureSuccessStatusCode();

Worth noting that the json content above it's presented as a simple string to simplify the code. There is a json library available to help with serializing and deserializing from/to C# classes, even the most complex ones.

Again, note the call to response.EnsureSuccessStatusCode(); to make sure the HTTP request was successfully performed.

Download binary content to a file

Using HttpClient makes it easy to deal with binary content too. Here's an example of how to download a file from a webserver.

HttpResponseMessage response = _httpClient.Get("https://storage-on-the-cloud.net/file-with-binary-content");
response.EnsureSuccessStatusCode();

using FileStream fs = new FileStream($"I:\\i-am-a-binary-file.bin", FileMode.Create, FileAccess.Write);
response.Content.ReadAsStream().CopyTo(fs);

Debugging through a reverse proxy

When code is deployed to a MCU it might be desirable to let the device connect to your development machine running IIS Express. This can be achieved with a proxy such as this one. Be aware that this leads to SocketExceptions with the current version of nanoFramework System.Net.Http when sending consecutive requests to your development machine. A simple retry mechanism in Debug mode will get around this.

Feedback and documentation

For documentation, providing feedback, issues and finding out how to contribute please refer to the Home repo.

Join our Discord community here.

Credits

The list of contributors to this project can be found at CONTRIBUTORS.

License

The nanoFramework Class Libraries are licensed under the MIT license.

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the .NET Foundation Code of Conduct.

.NET Foundation

This project is supported by the .NET Foundation.

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (14)

Showing the top 5 NuGet packages that depend on nanoFramework.System.Net.Http:

Package Downloads
nanoFramework.System.Net.WebSockets

This package includes the System.Net.WebSockets assembly for nanoFramework C# projects. There are also two other packages with just the client API and just the server API. These are meant to be used when there is the need to use smaller assemblies.

nanoFramework.System.Net.WebSockets.Server

This package includes the System.Net.WebSockets assembly (server API only) for .NET nanoFramework C# projects. There are also two other packages, one with the client API only and another with the complete API.

MakoIoT.Device.Services.ConfigurationManager

Configuration mode manager for MAKO-IoT

MakoIoT.Device.Services.Server

Simple WebServer for .NET nanoFramework C# projects. Based on nanoFramework.WebServer by Laurent Ellerbach and contributors

MakoIoT.Device.Services.ConfigurationApi

REST API for configuration with MAKO-IoT

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on nanoFramework.System.Net.Http:

Repository Stars
dotnet/samples
Sample code referenced by the .NET documentation
nanoframework/Samples
🍬 Code samples from the nanoFramework team used in testing, proof of concepts and other explorational endeavours
nanoframework/nanoFramework.IoT.Device
📦 This repo includes .NET nanoFramework implementations for various sensors, chips, displays, hats and drivers
Version Downloads Last Updated
1.5.200 1,232 11/19/2025
1.5.199 563 11/13/2025
1.5.196 4,646 6/2/2025
1.5.195 1,473 4/24/2025
1.5.193 2,794 4/2/2025
1.5.192 1,402 3/26/2025
1.5.191 628 3/26/2025
1.5.189 2,272 3/10/2025
1.5.188 346 3/10/2025
1.5.187 334 3/10/2025
1.5.186 336 3/10/2025
1.5.184 1,619 3/3/2025
1.5.183 1,220 2/27/2025
1.5.182 283 2/27/2025
1.5.181 738 2/25/2025
1.5.180 381 2/25/2025
1.5.179 367 2/25/2025
1.5.178 368 2/25/2025
1.5.177 270 2/25/2025
1.5.175 2,924 2/5/2025
1.5.172 1,330 1/30/2025
1.5.171 263 1/30/2025
1.5.170 274 1/30/2025
1.5.169 267 1/30/2025
1.5.165 385 1/27/2025
1.5.162 727 1/6/2025
1.5.161 199 1/6/2025
1.5.159 166 1/6/2025
1.5.158 208 1/6/2025
1.5.157 563 1/2/2025
1.5.150 6,052 9/26/2024
1.5.145 5,274 7/30/2024
1.5.138 6,444 5/13/2024
1.5.136 1,068 5/10/2024
1.5.134 2,701 4/8/2024
1.5.132 824 4/8/2024
1.5.130 1,307 4/3/2024
1.5.128 372 4/3/2024
1.5.125 4,817 1/29/2024
1.5.118 2,308 1/24/2024
1.5.113 12,515 11/10/2023
1.5.110 216 11/9/2023
1.5.108 1,107 11/9/2023
1.5.106 2,116 11/3/2023
1.5.104 2,676 10/10/2023
1.5.102 3,132 10/4/2023
1.5.99 6,123 8/8/2023
1.5.97 1,091 7/27/2023
1.5.95 343 7/27/2023
1.5.84 7,292 2/17/2023
1.5.82 2,090 1/24/2023
1.5.78 3,067 12/28/2022
1.5.75 677 12/28/2022
1.5.73 650 12/28/2022
1.5.70 1,904 12/27/2022
1.5.68 597 12/22/2022
1.5.61 2,950 11/23/2022
1.5.54 3,784 10/26/2022
1.5.52 2,544 10/26/2022
1.5.50 2,098 10/26/2022
1.5.48 2,344 10/25/2022
1.5.45 1,148 10/25/2022
1.5.43 2,581 10/24/2022
1.5.41 1,150 10/24/2022
1.5.39 582 10/24/2022
1.5.37 2,405 10/23/2022
1.5.35 606 10/23/2022
1.5.30 3,600 10/10/2022
1.5.27 3,872 10/8/2022
1.5.24 4,298 9/22/2022
1.5.22 4,436 9/22/2022
1.5.20 4,164 9/15/2022
1.5.18 1,219 9/15/2022
1.5.13 3,421 8/5/2022
1.5.10 4,106 8/4/2022
1.5.8 922 8/4/2022
1.5.6 1,153 8/4/2022
1.5.4 2,537 8/3/2022
1.5.2 1,248 8/3/2022
1.4.0.25 896 8/3/2022
1.4.0.23 3,835 6/13/2022
1.4.0.21 2,834 6/8/2022
1.4.0.19 2,466 6/8/2022
1.4.0.14 2,678 5/26/2022
1.4.0.12 4,795 5/18/2022
1.4.0.10 4,531 5/3/2022
1.4.0 4,675 3/28/2022
1.4.0-preview.52 268 3/28/2022
1.4.0-preview.51 273 3/28/2022
1.4.0-preview.50 277 3/28/2022
1.4.0-preview.48 293 3/28/2022
1.4.0-preview.47 271 3/28/2022
1.4.0-preview.46 274 3/28/2022
1.4.0-preview.44 327 3/17/2022
1.4.0-preview.43 280 3/17/2022
1.4.0-preview.42 313 3/14/2022
1.4.0-preview.41 275 3/14/2022
1.4.0-preview.40 264 3/14/2022
1.4.0-preview.39 284 3/14/2022
1.4.0-preview.37 272 3/14/2022
1.4.0-preview.36 377 3/8/2022
1.4.0-preview.35 291 3/8/2022
1.4.0-preview.33 297 3/4/2022
1.4.0-preview.32 273 3/3/2022
1.4.0-preview.31 278 3/2/2022
1.4.0-preview.29 345 2/28/2022
1.4.0-preview.28 366 2/24/2022
1.4.0-preview.26 342 2/17/2022
1.4.0-preview.24 318 2/17/2022
1.4.0-preview.22 375 2/6/2022
1.4.0-preview.21 337 2/4/2022
1.4.0-preview.19 284 2/4/2022
1.4.0-preview.18 357 1/28/2022
1.4.0-preview.16 285 1/28/2022
1.4.0-preview.15 295 1/28/2022
1.4.0-preview.13 288 1/28/2022
1.4.0-preview.12 316 1/21/2022
1.4.0-preview.6 399 1/12/2022
1.4.0-preview.5 311 1/12/2022
1.4.0-preview.4 297 1/11/2022
1.4.0-preview.3 284 1/11/2022
1.3.7-preview.8 344 1/5/2022
1.3.7-preview.7 346 1/3/2022
1.3.7-preview.6 302 1/3/2022
1.3.7-preview.5 291 1/3/2022
1.3.7-preview.4 319 12/30/2021
1.3.7-preview.3 303 12/28/2021
1.3.6 951 12/3/2021
1.3.6-preview.23 342 12/3/2021
1.3.6-preview.21 299 12/3/2021
1.3.6-preview.20 318 12/2/2021
1.3.6-preview.19 291 12/2/2021
1.3.6-preview.18 298 12/2/2021
1.3.6-preview.17 311 12/2/2021
1.3.6-preview.16 299 12/2/2021
1.3.6-preview.14 298 12/2/2021
1.3.6-preview.12 311 12/2/2021
1.3.6-preview.10 319 12/1/2021
1.3.6-preview.7 322 12/1/2021
1.3.6-preview.1 473 11/11/2021
1.3.5-preview.8 423 10/22/2021
1.3.5-preview.5 341 10/18/2021
1.3.4 1,869 7/16/2021
1.3.4-preview.78 307 7/16/2021
1.3.4-preview.76 331 7/16/2021
1.3.4-preview.74 298 7/16/2021
1.3.4-preview.72 322 7/15/2021
1.3.4-preview.70 319 7/14/2021
1.3.4-preview.68 869 6/19/2021
1.3.4-preview.66 403 6/19/2021
1.3.4-preview.64 323 6/17/2021
1.3.4-preview.62 357 6/7/2021
1.3.4-preview.60 317 6/7/2021
1.3.4-preview.58 348 6/7/2021
1.3.4-preview.56 360 6/6/2021
1.3.4-preview.54 368 6/3/2021
1.3.4-preview.52 337 6/2/2021
1.3.4-preview.50 327 6/1/2021
1.3.4-preview.48 330 6/1/2021
1.3.4-preview.41 353 5/25/2021
1.3.4-preview.39 379 5/21/2021
1.3.4-preview.37 379 5/20/2021
1.3.4-preview.35 324 5/19/2021
1.3.4-preview.33 320 5/19/2021
1.3.4-preview.31 338 5/19/2021
1.3.4-preview.29 309 5/15/2021
1.3.4-preview.27 318 5/15/2021
1.3.4-preview.25 304 5/15/2021
1.3.4-preview.23 335 5/13/2021
1.3.4-preview.22 320 5/13/2021
1.3.4-preview.20 340 5/11/2021
1.3.4-preview.18 385 5/6/2021
1.3.4-preview.16 312 5/6/2021
1.3.4-preview.14 307 5/5/2021
1.3.4-preview.13 310 5/5/2021
1.3.4-preview.10 361 4/10/2021
1.3.4-preview.9 368 4/9/2021
1.3.4-preview.7 341 4/5/2021
1.3.3-preview.65 419 3/20/2021
1.3.3-preview.62 358 3/19/2021
1.3.3-preview.60 322 3/17/2021
1.3.3-preview.57 332 3/17/2021
1.3.3-preview.55 367 3/2/2021
1.3.3-preview.50 563 1/19/2021
1.3.3-preview.47 371 1/6/2021
1.3.3-preview.40 355 12/29/2020
1.3.3-preview.34 451 12/7/2020
1.3.3-preview.32 382 12/7/2020
1.3.3-preview.27 432 11/3/2020
1.3.3-preview.25 413 10/26/2020
1.3.3-preview.23 432 10/21/2020
1.3.3-preview.17 429 10/20/2020
1.3.3-preview.15 482 10/1/2020
1.3.3-preview.11 399 9/30/2020
1.3.3-preview.9 405 9/30/2020
1.3.3-preview.7 441 9/27/2020
1.3.3-preview.5 453 9/27/2020
1.3.3-preview.1 399 9/24/2020
1.3.2-preview.3 435 9/19/2020
1.3.2-preview.1 503 8/25/2020
1.3.1-preview.6 459 7/2/2020
1.3.1-preview.3 486 6/30/2020
1.3.0 978 6/16/2020
1.3.0-rc.3 477 6/16/2020
1.3.0-preview.11 461 6/16/2020
1.3.0-preview.9 411 6/16/2020
1.3.0-preview.7 407 6/16/2020
1.3.0-alpha.12 458 6/16/2020
1.3.0-alpha.10 407 6/16/2020
1.3.0-alpha.8 405 6/16/2020
1.2.2 683 6/12/2020
1.2.2-preview.41 419 6/12/2020
1.2.2-preview.39 421 6/12/2020
1.2.2-preview.34 422 6/3/2020
1.2.2-preview.33 439 6/3/2020
1.2.2-preview.31 556 5/31/2020
1.2.2-preview.30 429 5/31/2020
1.2.2-preview.29 461 5/31/2020
1.2.2-preview.28 430 5/29/2020
1.2.2-preview.27 470 5/8/2020
1.2.2-preview.26 433 5/8/2020
1.2.2-preview.25 446 4/27/2020
1.2.2-preview.24 427 4/24/2020
1.2.2-preview.23 443 4/21/2020
1.2.2-preview.22 468 4/16/2020
1.2.2-preview.19 491 4/16/2020
1.2.2-preview.18 443 4/14/2020
1.2.2-preview.17 449 4/14/2020
1.2.2-preview.16 424 4/14/2020
1.2.2-preview.15 477 3/25/2020
1.2.2-preview.14 475 3/15/2020
1.2.2-preview.13 522 3/10/2020
1.2.2-preview.12 451 3/10/2020
1.2.2-preview.10 417 3/10/2020
1.2.2-preview.8 421 3/10/2020
1.2.2-preview.7 421 3/10/2020
1.2.2-preview.6 453 3/9/2020
1.2.2-preview.5 445 3/9/2020
1.2.2-preview.4 437 3/6/2020
1.2.2-preview.3 505 1/13/2020
1.2.2-preview.2 531 11/14/2019
1.2.2-preview.1 448 11/12/2019
1.2.2-alpha.42 402 6/12/2020
1.2.2-alpha.40 417 6/12/2020
1.2.2-alpha.38 445 6/11/2020
1.2.2-alpha.35 429 6/3/2020
1.2.2-alpha.34 432 6/3/2020
1.2.2-alpha.32 510 5/31/2020
1.2.2-alpha.31 444 5/31/2020
1.2.2-alpha.30 442 5/30/2020
1.2.2-alpha.29 428 5/29/2020
1.2.2-alpha.28 457 5/8/2020
1.2.2-alpha.27 433 5/8/2020
1.2.2-alpha.26 420 4/27/2020
1.2.2-alpha.23 468 4/16/2020
1.2.2-alpha.21 458 4/16/2020
1.2.2-alpha.20 471 4/16/2020
1.2.2-alpha.19 410 4/14/2020
1.2.2-alpha.18 426 4/14/2020
1.2.2-alpha.17 428 4/14/2020
1.2.2-alpha.16 484 3/25/2020
1.2.2-alpha.15 485 3/15/2020
1.2.2-alpha.14 423 3/10/2020
1.2.2-alpha.13 411 3/10/2020
1.2.2-alpha.11 423 3/10/2020
1.2.2-alpha.10 425 3/10/2020
1.2.2-alpha.9 426 3/10/2020
1.2.2-alpha.8 448 3/9/2020
1.2.2-alpha.7 455 3/9/2020
1.2.2-alpha.6 468 3/9/2020
1.2.1-preview.3 442 11/8/2019
1.2.1-preview.1 460 11/5/2019
1.2.0-preview.3 468 10/18/2019
1.1.0 877 10/17/2019
1.1.0-preview.3 443 10/17/2019
1.0.8-preview.7 439 10/17/2019
1.0.8-preview.5 458 10/15/2019
1.0.8-preview.4 485 9/30/2019
1.0.8-preview.1 469 8/30/2019
1.0.7-preview.1 462 8/30/2019
1.0.6-preview.33 470 8/19/2019
1.0.6-preview.30 492 7/19/2019
1.0.6-preview.26 590 6/23/2019
1.0.6-preview.19 510 6/20/2019
1.0.6-preview.17 496 6/14/2019
1.0.6-preview.14 520 6/12/2019
1.0.6-preview.10 497 6/12/2019
1.0.6-preview.6 511 6/5/2019
1.0.6-preview.4 512 6/5/2019
1.0.6-preview.2 496 5/31/2019
1.0.5-preview-038 771 4/24/2019
1.0.5-preview-036 785 4/23/2019
1.0.5-preview-031 694 4/7/2019
1.0.5-preview-028 719 4/5/2019
1.0.5-preview-026 677 4/5/2019
1.0.5-preview-024 682 4/3/2019
1.0.5-preview-022 734 3/27/2019
1.0.5-preview-020 675 3/26/2019
1.0.5-preview-017 696 3/26/2019
1.0.5-preview-009 696 3/25/2019
1.0.5-preview-007 682 3/15/2019
1.0.5-preview-004 729 3/11/2019
1.0.5-preview-002 685 3/11/2019
1.0.5-preview-001 740 3/11/2019
1.0.4 1,266 1/22/2019
1.0.4-preview-009 706 3/10/2019
1.0.4-preview-003 849 1/3/2019
1.0.3 994 12/17/2018
1.0.2 982 11/15/2018
1.0.2-preview-009 854 11/20/2018
1.0.2-preview-005 852 11/8/2018