I have been struggling with this issue for almost a month now, and I read everything I could find online, with no solution. Here's my problem: I'm implementing a client for a RESTful API service that has to send an XML file through a POST call, in vb.net. I am able to make it working when it comes to GET some data, in xml format, but when it comes to send this Xml file, I always get the "400 bad request error".I already figured it out that it has to be a matter of the key that has to be passed to the server (that apparently accepts only file uploading for POST, I cannot send it as a string).Basically this call works with cURL, but I am struggling for implementing my own call in vb.net, passing the right value. Working cURL call: (that successfully transmits the XML)\[code\] `c:>curl -u usernameassword -F "[email protected]" -X POST http://hostname.com/URI?parameters`\[/code\]Not working Vb.net code: (that gives me 400 Bad Request)\[code\] ` Dim ss As String = "" 'server says... Dim S As String = txb_username.Text & ":" & txb_password.Text Dim EncodedString As String = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(S)) Dim req As HttpWebRequest = Nothing Dim res As HttpWebResponse = Nothing Try Dim xmlDoc As System.Xml.XmlDocument = New System.Xml.XmlDocument xmlDoc.XmlResolver = Nothing xmlDoc.Load("c:\path\file4.xml") Dim sXML As String = "file" & xmlDoc.InnerXml '<- This is where I try to put the "KEY" Dim url As String = "http:/host.com+URI" req = CType(WebRequest.Create(url), Net.HttpWebRequest) 'or Directcast ... req.Method = "POST" req.Headers.Add("Authorization: Basic " & EncodedString) req.ContentType = "multipart/form-data" req.ContentLength = sXML.Length req.Accept = "*/*" System.Windows.Forms.Application.DoEvents() Dim sw As System.IO.StreamWriter = New System.IO.StreamWriter(req.GetRequestStream) StatusUpdate(sXML) sw.Write(sXML) sw.Close() ss = "server says: " res = CType(req.GetResponse, HttpWebResponse) StatusUpdate(req.ToString) Catch ex As Exception StatusUpdate(ss & ex.Message) Finally End Try `\[/code\]Is it because I am trying to send it as a string? (but how else can I send it as a file?)In any case, I tried also other 2 clients (POSTMAN and REST Console, 2 extensions for Google Chrome) and I can get it working only if I add the value "file" into the "key" field. I have to insert the specific 4 chars "file" to get it working. So, the question is: how do I add the same value in a Vb.net call? How can I translate the code of the cURL call in working Vb.net code? Thank you very much for your time and help!!!find image at this link: http://i.stack.imgur.com/FVt3v.jpgP.S. I cannot use PUT, I have to use POST (server restriction)