Skip to content

Commit

Permalink
feat(doc): added example of getting image with request class
Browse files Browse the repository at this point in the history
  • Loading branch information
sikelio committed Aug 5, 2024
1 parent 97cd495 commit e406a4a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 19 additions & 1 deletion Web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ string url = "your-url";
Request request = new(url);
request
.AddHeader("key", "value")
.AcceptJson()
.AcceptJson();

Result<MyModel> result = await request.Run<MyModel>();

Expand All @@ -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<byte[]> result = await request.RunGetBytes();

if (result.StatusCode == 200 && result.Value != null)
{
File.WriteAllBytes($"image.png", result.Value);
}
```

0 comments on commit e406a4a

Please sign in to comment.