Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Anzeige
Inhaltsverzeichnis

VBA: Datei Upload mit http: POST

Forumthread: VBA: Datei Upload mit http: POST

VBA: Datei Upload mit http: POST
25.10.2025 17:10:14
Robert Hoch
Hallo,

schönen Gruß an alle; ich hoffe jemand hat einen Hinweis wo ich ansetzen kann.

Problembeschreibung:
• VBA aus Excel (das muss auch so bleiben) und funktioniert anscheinend ja auch (zumindest bei Anderen im Forum, die mit den Lösungen zufrieden waren)
• seit einigen Tagen versuche ich eine Datei per POST hochzuladen
• habe bereits Vieles versucht und Foren, sowie den API-Provider durchkämmt
• leider ohne Erfolg
• bekomme immer eine Fehlermeldung: "error": "internal_error"
• Manuelles Upload und automatische Auswertung mit Excel-VBA (GET) klappt.
• mein Test-VBA Code und Beispiel-Codes vom Provider in CURL + Python anbei (hier veröffentlichte API-key ist natürlich fake)
• bitte keine Hinweise wie, ich sollte es mit einer anderen Programmiersprache versuchen

Vielen Dank im Voraus
Robert

https://developer.millionverifier.com/#operation/bulk-upload


Beispiel: Python-Code

import requests
url = "https://bulkapi.millionverifier.com/bulkapi/v2/upload?key=your-api-key"
files=[
('file_contents',('filename',open('path/to/file','rb'),'text/plain'))
]
response = requests.request("POST", url, files=files)
print(response.text)

Beispiel: CURL-Code

curl --location --request POST 'https://bulkapi.millionverifier.com/bulkapi/v2/upload?key=your-api-key' \
--form 'file_contents=@"path/to/file"'


---------------------------------------------------------------------------------------------------------------------------------------------------------------
VBA-Code

Public Sub UploadFile()
Dim sFormData, bFormData
Dim d As String, DestURL As String, fileName As String, filePath As String, FieldName As String, content As String
Dim ado As Object

Const Boundary As String = "---------------------------0123456789012"
' Const DEALID As String = "9822"
FieldName = "file"
DestURL = "https://bulkapi.millionverifier.com/bulkapi/v2/upload?key=xxxxxxxxxxxxxxxxxxx"
fileName = "Email_Bulk-Verifikation.txt"
content = "text/plain"

filePath = "E:\" + fileName

Dim File, FILESIZE
Set ado = CreateObject("ADODB.Stream")
ado.Type = 1 'binary
ado.Open
ado.LoadFromFile filePath
ado.Position = 0
FILESIZE = ado.Size
File = ado.Read
ado.Close

Set ado = CreateObject("ADODB.Stream")
d = "--" + Boundary + vbCrLf
' d = d + "Content-Disposition: form-data; name=""deal_id""" & vbCrLf & vbCrLf
d = d + "Content-Disposition: form-data" & vbCrLf
' d = d + DEALID & vbCrLf
d = d + "--" + Boundary + vbCrLf
d = d + "Content-Disposition: form-data; name=""" + FieldName + """;"
d = d + " filename=""" + fileName + """" + vbCrLf
d = d + "Content-Type: " & content + vbCrLf + vbCrLf
ado.Type = 1 'binary
ado.Open
ado.Write ToBytes(d)
ado.Write File
ado.Write ToBytes(vbCrLf + "--" + Boundary + "--" + vbCrLf)
ado.Position = 0

With CreateObject("MSXML2.ServerXMLHTTP")
.Open "POST", DestURL, False
' .setRequestHeader "Content-Type", "multipart/form-data; boundary=" & Boundary
.SetRequestHeader "Content-Type", "text/plain; boundary=" & Boundary
.send ado.Read

Debug.Print .responseText
End With
End Sub

Function ToBytes(str As String) As Variant
Dim ado As Object
Set ado = CreateObject("ADODB.Stream")
ado.Open
ado.Type = 2 ' text
ado.Charset = "_autodetect"
ado.WriteText str
ado.Position = 0
ado.Type = 1
ToBytes = ado.Read
ado.Close
End Function

Anzeige

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: VBA: Datei Upload mit http: POST
26.10.2025 11:04:58
schauan
.. und andere Lösungen gehen auch nicht?

https://wqweto.wordpress.com/2011/07/12/vb6-using-wininet-to-post-binary-file/

https://www.ericphelps.com/scripting/samples/reference/web/http_post.txt

( https://www.youtube.com/watch?v=U-W_f7FsVz4 )

...

scheint auch dringlich zu sein, 36 Minuten vorher:
https://www.office-hilfe.com/support/threads/vba-datei-upload-mit-http-post.59992/
Anzeige
AW: VBA: Datei Upload mit http: POST
26.10.2025 17:54:17
Robert Hoch
Hallo schauan,

danke für die Antwort. Bis auf 'ericshelp' kannte ich die Links schon.
Hab's auch ausprobiert, ohne Erfolg; bis auf YouTube (nicht anwendbar)

Ich werd mich wohl noch näher mit dem RequestHeader befassen müssen.
-> siehe
files=[

('file_contents',('filename',open('path/to/file','rb'),'text/plain'))
]

Als Rückfallposition ist manuelles Upload noch möglich. Allerdings würde ich es gerne vollautomatisieren.

Hätte nicht gedacht, dass ich mich mit binary-Dateien befassen muss.


Anzeige
AW: VBA: Datei Upload mit http: POST
27.10.2025 08:28:36
schauan
Hallöchen,

bei administrator.de findest Du auch einiges zum thema ftp und curl...
https://administrator.de/forum/page/1/?search=upload%20script

Ggf. kann man auch mit anderen Progammen was erreichen, z.B.
https://stackoverflow.com/questions/24945709/schedule-automatic-daily-upload-with-filezilla

Entsprechende Scripte kann man ja dann aus vba heraus aufrufen bzw. auch gleich von vba erstellen lassen ...


ist bei mir schon recht lange her, dass ich mich damit beschäftigen musste. Mein letzter Stand war was in der Art: ;-)
https://administrator.de/forum/shell-script-fuer-ftp-upload-147298.html

filename="/home/paul/myfile.tar.gz"  

hostname="ftp.myhost.com"
username="username"
password="password"
ftp -un $hostname
quote USER $username
quote PASS $password

binary
put $filename
quit
EOF


Anzeige
Anzeige
Anzeige
Live-Forum - Die aktuellen Beiträge
Datum
Titel
14.05.2026 13:31:09
14.05.2026 09:50:42
13.05.2026 19:14:18