Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8456231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:29:38+00:00 2026-06-10T12:29:38+00:00

I have this code in Visual Basic .net and I would like to make

  • 0

I have this code in Visual Basic .net and I would like to make the same thing in Visual Basic 6. The code upload an image to a given URL. I have to use Rest protocol because the server I upload the image request it.

 Dim res As New RestSharp.RestRequest("URL_OF_SERVER", RestSharp.Method.POST)

 res.AddFile("file", "File_location_on_PC")
 Dim restClient As New RestSharp.RestClient()

 Dim r As New RestSharp.RestResponse
 r = restClient.Execute(res)

Is it posible to do the same Rest Protocol in Visual Basic 6?

EDIT 1: I HAVE TRIED THIS BUT AN ERROR HAPPENS

Dim xmlhttp As MSXML2.XMLHTTP30
Const STR_BOUNDARY  As String = "3fbd04f5-b1ed-4060-99b9-fca7ff59c113"
Dim nFile           As Integer
Dim baBuffer()      As Byte
Dim sPostData       As String

'--- read file
nFile = FreeFile
Open NombreArchivo For Binary Access Read As nFile
If LOF(nFile) > 0 Then
    ReDim baBuffer(0 To LOF(nFile) - 1) As Byte
    Get nFile, , baBuffer
    sPostData = StrConv(baBuffer, vbUnicode)
End If
Close nFile
'--- prepare body
sPostData = "--" & STR_BOUNDARY & vbCrLf & _
"   Content-Disposition: form-data; name=""image002""; filename=""C:\image002.jpg" & _
"--" & STR_BOUNDARY & "--"
'--- post
Set xmlhttp = New MSXML2.XMLHTTP30
With xmlhttp
    .Open "POST", Url, False
    .setRequestHeader "Content-Type", "multipart/form-data; boundary=" & STR_BOUNDARY
    .send pvToByteArray(sPostData)
End With

Private Function pvToByteArray(sText As String) As Byte()
   pvToByteArray = StrConv(sText, vbFromUnicode)
End Function

ERROR :

responseText
{"message":"file.not_found","error":"There is no file in request.","status":400,"cause":[]}

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:29:40+00:00Added an answer on June 10, 2026 at 12:29 pm

    If you need just to post a file here is a simple function

    Private Sub pvPostFile(sUrl As String, sFileName As String, Optional ByVal bAsync As Boolean)
        Const STR_BOUNDARY  As String = "3fbd04f5-b1ed-4060-99b9-fca7ff59c113"
        Dim nFile           As Integer
        Dim baBuffer()      As Byte
        Dim sPostData       As String
    
        '--- read file
        nFile = FreeFile
        Open sFileName For Binary Access Read As nFile
        If LOF(nFile) > 0 Then
            ReDim baBuffer(0 To LOF(nFile) - 1) As Byte
            Get nFile, , baBuffer
            sPostData = StrConv(baBuffer, vbUnicode)
        End If
        Close nFile
        '--- prepare body
        sPostData = "--" & STR_BOUNDARY & vbCrLf & _
            "Content-Disposition: form-data; name=""uploadfile""; filename=""" & Mid$(sFileName, InStrRev(sFileName, "\") + 1) & """" & vbCrLf & _
            "Content-Type: application/octet-stream" & vbCrLf & vbCrLf & _
            sPostData & vbCrLf & _
            "--" & STR_BOUNDARY & "--"
        '--- post
        With CreateObject("Microsoft.XMLHTTP")
            .Open "POST", sUrl, bAsync
            .SetRequestHeader "Content-Type", "multipart/form-data; boundary=" & STR_BOUNDARY
            .Send pvToByteArray(sPostData)
        End With
    End Sub
    
    Private Function pvToByteArray(sText As String) As Byte()
        pvToByteArray = StrConv(sText, vbFromUnicode)
    End Function
    

    You can switch to MSXML2.ServerXMLHTTP to be able to use its SetTimeouts method if your file is large enough and timeouts in 30 sec.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a collection in Visual Basic.net (Sorry if people are seeing this code
I'm converting Visual Basic.Net code to C# in my project. But I have some
I have this property in a visual basic class. NET 2008, the property in
Well I have this code in my Managed C++/Cli in Visual Studio 2008, I
I have a MS-Visual Studio 2005 workspace having all c code. This application(exe) allocates
I have this code for changing the image of a button: - (void)mouseEntered:(NSEvent *)event
I'm fairly new to Visual Studio (specifically Visual Basic .NET) but have been programming
I want get the most specific from the current url in visual basic .net.
I would like to refactor a large legacy application originally written in Visual Basic
I have a basic ASP.Net project created in Visual Studio 2008 on Windows Server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.