I have a problem which is really frustrating me and I'm having trouble solving it. My team has assembled a small solution in C# which should send a file to an API. File is being sent via HTTP post request.
Solution consists of a service which sends the file and API which receives it. When both service and API are on the same computer it works perfectly but when API is deployed on the server it fails to receive the file. Receiving code is simple:
public HttpResponseMessage Post()
{
httpResponseMessage result = null;
var httpRequest = HttpContext.Current.Request;
//do sth with the file set response
return response;
}
request is received but the problem is when I access
httpRequest.Files
it is empty. As sugested by microsoft documentation this should be autopopulated with files in multipart/form-data type. When I call
httpRequest.ContentLength
it is exactly what was sent and
httpRequest.ContentType
multipart/form-data;
So data is received but API does not recognize the files. Is there any way to get API to recognize the files, and if not is there any manual way to parse the files from the response body.