Topic Options
#56142 - 07/25/18 05:07 PM Upload PDF via HTTP POST
Alikeware Offline
OL Newbie

Registered: 02/14/08
Posts: 26
Loc: USA, Maryland
I need some help. I am trying to script my way into uploading a PDF file to a server via HTTP POST, but cannot make it work. Here is what I need the POST to look like:

URL -> https://<url>/api/v2/job/24/executeTransition?_json{"transition_name":"upload_first_revision"}

In the body I need to attach a file with a field name called "artwork". I have tried this script but the server is complaining about not "understanding" the file type uploaded.

Option Explicit
' Main
' Declare variables.
Dim payload, HTTPPost, oHTTP, postURL

' Setup variable

payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW"+VbCrLf+"Content-Disposition: form-data; name=""artwork""; filename=""D:\e_Brain\AUTOMATION\tBOT\PDF_IN\165501-1_Test Company_V1.pdf"""+VbCrLf
payload = payload + "Content-Type: application/pdf"+VbCrLf+VbCrLf+VbCrLf+"------WebKitFormBoundary7MA4YWxkTrZu0gW--"

Watch.Log payload, 2


postURL = "{""transition_name"":""upload_first_revision""}"

set oHTTP = CreateObject("Msxml2.ServerXMLHTTP") "POST", postURL,false
oHTTP.setRequestHeader "Authorization", "EeHSIFaDlJzmmylrslaoYT8QyV2iUsjbPSCLufpY"
oHTTP.setRequestHeader "Content-Type", "multipart/form-data"
oHTTP.setRequestHeader "content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"
oHTTP.send payload


#56148 - 07/26/18 11:22 AM Re: Upload PDF via HTTP POST [Re: Alikeware]
Raphael Lalonde Lefebvre Offline
OL Expert

Registered: 10/14/05
Posts: 4954
Loc: Objectif Lune Montreal
Hi Alikeware,

Besides the "Watch.Log", there doesn't seem to be anything else related to PlanetPress Workflow in this script, so I don't think we can really offer you much help, we do not officially provide support for custom scripts. Does this script work outside of PlanetPress Workflow? If it doesn't, then looking for vbscripts reference sites, or any websites for programmers might be a better place to look for advice. (sites such as are often a great place to look for advice and ask questions on scripts and codes)

Raphaƫl Lalonde-Lefebvre