 |
|
 |
Subject: uploading a binary file (.pdf) to a third party website using ServerXMLHTTP |
 |
 |
 |
Product Area: Notes Client |
 |
Technical Area: Application Development |
 |
Platform: Windows |
 |
Release: 8.5.3 |
 |
Reproducible: Not attempted |
 |
 |
 |
 |
Hi, I'm trying to upload a binary file to a third party website using objHTTP = CreateObject("MSXML2.ServerXMLHTTP.3.0"). I've managed to log in to their system via their API, and navigate their folder system. I can upload text files, but I have a problem with binary files. The issue is I have to put some text at the start of the file, specifically...
--NEXT_PART_4578577.12021
Content-Disposition: form-data; name="options"
{
"folder" : "aa28796xxxxxxxxxxx0e54c",
"filename" : "C:\\Data\\filename.ext",
"name" : "xyxyxyxyxyx",
"description" : "xyxyxyxy"
}
--NEXT_PART_4578577.12021
Content-Disposition: form-data; name=file1; filename="C:\\Data\\filename.ext"
Content-Type : text/plain
.
.
.
.
--NEXT_PART_4578577.12021--
My process is to create a string (sOutputData) with the equal to the stuff above (I stream the contents of the text file in the .... bit using NotesStream.ReadText). Having setup our sOutputData string, I then send it (see below) and it works!
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP.3.0")
objHTTP.Open "POST", sTargetURL & "/resources" & "?p10=" & g_sAPIKey & "&p20=" & g_sUserUUID & "&folderuuid=" & varChosenFolderItems("folderuuid"), False
objHTTP.SetRequestHeader "Cookie", g_sCookie
objHTTP.SetRequestHeader "Content-Type", "multipart/form-data; boundary=" & sBoundary' & "; Charset=Unicode"
objHTTP.Send(sOutputData)
This works fine for text and NotesStream.ReadText (stream.ReadText returns a string, whereas stream.Read returns a variant array of bytes). But if I try to include my binary file stream in the middle of the sOutputData string I get "Type Mismatch"!!!
Has anybody got any ideas?
Regards
Tim
 
Feedback number WEBBAGV2MP created by ~Judy Eltooburoden on 12/22/2016

Status: Open
Comments:

uploading a binary file (.pdf) to a... (~Judy Eltooburo... 22.Dec.16)
. . I still have this problem... (~Judy Eltooburo... 12.Apr.17)
. . . . Bump (~Judy Eltooburo... 29.May.17) |
|  |
|