title: Unable to upload a text file using vba
body: <p>I'm trying to upload a tiny text file in a website using vba. When I run the script I encounter this error <code>{"success":false,"error":400,"message":"Trouble uploading file"}</code>. I mimicked the same approach using vba that I did and found success using python. I got rid of the headers altogether in python so I suppose <code>multipart</code> headers is not that important to upload the file successfully.</p>
  
  <p>Using vba (I got the above error):</p>
  
  <pre><code>Sub UploadFile()
      Dim Http As New XMLHTTP60, sPostData$
      Dim nFile&amp;, baBuffer() As Byte
  
      nFile = FreeFile
      Open "C:\Users\WCS\Desktop\some_text.txt" For Binary Access Read As nFile
          If LOF(nFile) &gt; 0 Then
              ReDim baBuffer(0 To LOF(nFile) - 1) As Byte
              Get nFile, , baBuffer
              sPostData = StrConv(baBuffer, vbUnicode)
          End If
      Close nFile
  
  '    MsgBox sPostData 'to examine if it is able to print the text
  
      With Http
          .Open "POST", "https://file.io/"
          .setRequestHeader "x-requested-with", "XMLHttpRequest"
          .send ("file=" &amp; sPostData)
  
          Debug.Print .responseText
      End With
  End Sub
  </code></pre>
  
  <p>Using vba (another way but got the same error):</p>
  
  <pre><code>Sub UploadFile()
      Dim Http As New XMLHTTP60, sPostData$
  
      With CreateObject("ADODB.Stream")
          .Charset = "utf-8"
          .Open
          .LoadFromFile ("C:\Users\WCS\Desktop\some_text.txt")
          sPostData = .ReadText()
      End With
  
      With Http
          .Open "POST", "https://file.io/"
          .setRequestHeader "x-requested-with", "XMLHttpRequest"
          .send ("file=" &amp; sPostData)
  
          Debug.Print .responseText
      End With
  End Sub
  </code></pre>
  
  <p>Using python (I got success):</p>
  
  <pre><code>import requests
  
  url = 'https://file.io/'
  
  files = {
     'file': open('some_text.txt','rb') 
  }
  
  def upload_file(link):
      res = requests.post(link,files=files)
      print(res.content)
  
  if __name__ == '__main__':
      upload_file(url)
  </code></pre>
  
  <p>Btw, this is what the text file contains <code>hi there!!!</code></p>