WebAPI built-in formatters only support the following media types:
application/json
,
text/json
,
application/xml
,
text/xml
and
application/x-www-form-urlencoded
A quick look at what error means:
Quote:
The HTTP 415 Unsupported Media Type client error response code indicates that the server refuses to accept the request because the payload format is in an unsupported format.
The format problem might be due to the request's indicated Content-Type or Content-Encoding, or as a result of inspecting the data directly.
Reference:
415 Unsupported Media Type - HTTP | MDN[
^]
Now, in your context, you are trying to do:
API method that has to send both json and form-data format to the server
This means:
1. You need to make sure the server accepts multiple format as content type payload.
2. Once you are sure of that, then for
multipart/form-data
, which is what you are sending, look at
ASP.NET WebApi: MultipartDataMediaFormatter[
^]
Try out.