From e406a4a82d8e11caf8acb54b05310f0b4e4ff650 Mon Sep 17 00:00:00 2001 From: Sik Date: Mon, 5 Aug 2024 22:48:24 +0200 Subject: [PATCH] feat(doc): added example of getting image with request class --- README.md | 2 +- Web/README.md | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 69dc103..73752b9 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This repos contains tool classes in C# for multiple types of usage. * Shutdown: Shutdown a device through SMB with it's hostname or ip address. It only work for Windows devices. * WakeOnLan: Power on a device with it mac address. * `FrApp42.Web` - [Link](https://www.nuget.org/packages/FrApp42.Web) - * Request: Make API request for any of your C# projects. ⚠️ *SOAP request are not supported.* ⚠️ + * Request: Make API request for any of your C# projects. ⚠️ *SOAP requests are not supported.* ⚠️ ## Licence diff --git a/Web/README.md b/Web/README.md index 6edff7d..f452943 100644 --- a/Web/README.md +++ b/Web/README.md @@ -22,7 +22,7 @@ string url = "your-url"; Request request = new(url); request .AddHeader("key", "value") - .AcceptJson() + .AcceptJson(); Result result = await request.Run(); @@ -41,3 +41,21 @@ class MyModel public string Description { get; set; } } ``` + +### Get an image +```csharp +using FrApp42.Web.API; + +string url = "your-url"; + +Request request = new(url); +request + .AddHeader("Accept", "image/png"); + +Result result = await request.RunGetBytes(); + +if (result.StatusCode == 200 && result.Value != null) +{ + File.WriteAllBytes($"image.png", result.Value); +} +```