Invalid 'HttpContent' instance provided. It does not have a 'multipart' content-type header with a 'boundary' parameter

前端 未结 2 1508
栀梦
栀梦 2021-01-17 09:34

I\'m writing a web api that have a post method accepting files from uploaded from UI.

public async Task> PostAsync()
    {

                 


        
2条回答
  •  天涯浪人
    2021-01-17 10:20

    You are looking on the response header which is json format and this is ok for you.

    Your real problem is with the postman request, so just remove the 'Content-Type: multipart/form-data' entry from request header. It's enough to upload a file as form-data and send the request.

    Look what happen when you set the Content-Type manually vs. when you not:

    Postman knows to set both the content type and boundary, since you set only the content type

提交回复
热议问题