I'm following this blog post to upload an image using C# Web API.
The article explains how to do it using ARC and it works fine.
But when I'm trying to do the same using POSTMAN it's failing.
Here is my request snapshot.
I'm following this blog post to upload an image using C# Web API.
The article explains how to do it using ARC and it works fine.
But when I'm trying to do the same using POSTMAN it's failing.
Here is my request snapshot.
Humph! This was hell tricky. You are doing everything correct except that you are setting the
Content-Type
header explicitly in the tool. You must not do that. Whenever you attach the files inform-data
in theBody
tab in the tool, Postman auto-detects theContent-Type
and sends it in your post request.Setting up
Content-Type
to "multipart/form-data" involves a complex concept of setting up boundaries of multiple parts as detailed here. So setting upContent-Type
header explicitly messes up the request. Heavy lifting of setting up the boundaries is done automatically for you by postman tool which is why it doesn't want you to set thecontent-type
explicitly in this case. Please see how I've set onlyAuthorization
header while uploading the image file on my system:You might not even need this
Authorization
header if there isn't any authentication on your web server. So effectivelyHeaders
tab in your case should simply be empty i.e. no key value pairs at all.Note: Just for information, the correct content type for image files is
multipart/form-data
even though you don't need to set it explicitly in the tool.In the post you referrer to the data is being uploaded as "x-www-form-url-encoded"
Your Postman screen shot shows you are uploading it as "form-data"
Additionally, you adding a key "image01" where the ARC example doesn't appear to be sending a key.
If you want to upload the file using form-data you need a different approach: