1
I’m making a webAPI to receive files via post.
Customer will send via classic Vb with the following code:
Set content = CreateObject("MSXML2.XMLHTTP.6.0")
content.Open "POST", url, False
content.setRequestHeader "TOKEN", token
content.Send (ConteudoXML)
STR=content.readystate
ST=content.status
ST_TXT=content.statusText
ws = content.responseText
Response.write "<br>Status Read:" & STR & "<br>Status:" & ST & "<br>Status TXT:" & ST_TXT & "<br>Resposta:" & ws
Set content = Nothing
It is using ASP 1.0, so the sending code cannot be changed.
The receiving code I’m using is
if (!Request.Content.IsMimeMultipartContent("form-data")) {
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
var sPath = HttpContext.Current.Server.MapPath("~/certificados/");
var re = Request;
var headers = re.Headers;
MultipartFormDataStreamProvider provider = new MultipartFormDataStreamProvider(sPath);
var task = Request.Content.ReadAsMultipartAsync(provider);
return new HttpResponseMessage(HttpStatusCode.Created);
The problem is that the receiving code is not recognizing the file and is always returning Httpstatuscode.Unsupportedmediatype.
I will need to receive file that is in another format(.pfx) also.