I am trying to send an image and additional data, for example, userId
to my API. But, these are two different types.
How to send an image and some additional data in Postman?
From Postman tool - right pane select GET from DropDown, then enter your Web API url like http://localhost:<portnumber>/api/supplier and click on Send button. This will make a request to Web API server and get response. You can get response in JSON, XML, HTML, Text format.
For small files (eg up to 200 to 300 MB) you can use the following 2 tutorials to tell you the trick.
1 | 2
But if your file is too large (eg 500 megabytes up to several gigabytes) Better use the Chunk method (crushing the bulk file into smaller pieces and then uploading these pieces and eventually stacking them to the server)
The following table has implemented this feature well To do this, you need to write both the server-side of the code and the client-side of the plugin to do the chunking work (albeit handy but easier with the plugin) such as this Resumable.js plugin
Note: Be sure to run the program on Kestrel to run it, otherwise it has restrictions in IISExpress mode.
refrence : DotNetZoom Channle in Telegram
First, create an action which receives IFormData
and a string
caption ( you can put them in a separate class if you want ) :
[Route("api/[controller]")]
public class PostsController : ControllerBase
{
[HttpPost]
public async Task<IActionResult> Create(IFormFile image, string caption)
{
// Save image here
return Ok(caption);
}
}
and with Postman, simply submit a form-data request like this :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With