Home > Asp.net MVC > Post file to REST client API through C#

Post file to REST client API through C#

When you want to post file to Web API / REST client API through c#.  You can use below code in C# to post file using Multipart Form Post in C#.

Below is the HTML sample code:

you can post file simply as you are doing in asp.net mvc. After that you can use below C# code:

In the above code we have called the function MultipartFormDataPost function with multiple parameters. Below is the implmentation of this function:

That’s it.

Now you can post file to REST API.

This Article is TAGGED in , , , . BOOKMARK THE permalink.

2 thoughts on “Post file to REST client API through C#

  1. It saved a lot of my time. Awesome article. Can you please tell me how to pass the array in the REST API as a parameter for POST function. Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">