Pradeep KUMAR

Pradeep KUMAR

  • NA
  • 39
  • 4k

C# File upload through API Bad request error

Sep 21 2018 6:12 PM
Hi all i have been trying to post files for a third party tool through rest api with MultipartFormDataContent. Even though i am writing files to MultipartFordatacontent in byte arry i am receiving error saying "400 bad request no filedata section found in multipart post request".
Request:
Method: POST, RequestUri: 'url', Version: 1.1, Content: System.Net.Http.MultipartFormDataContent, Headers:
{
Content-Type: multipart/form-data; boundary="c4757eb4-aefd-450a-a5cc-e879ac7f37ce"
Content-Length: 185
}
--c4757eb4-aefd-450a-a5cc-e879ac7f37ce
Content-Disposition: form-data; name=filedata; filename=pp.txt
Content-Type: text/plain
test file
--c4757eb4-aefd-450a-a5cc-e879ac7f37ce--
Response:
StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
x-transaction-id: 99999_staging_1537571048380:f4eb3ca701:28:jm91oq79:10113
vary: accept-encoding
Connection: keep-alive
Cache-Control: no-cache
Date: Fri, 21 Sep 2018 23:04:08 GMT
Content-Length: 104
Content-Type: application/json; charset=utf-8
}
{"statusCode":400,"error":"Bad Request","message":"No filedata section found in multipart POST request"}

Answers (1)