Hi, I’m looking for help file with upload through the API from VBA (using MS Access).
I can upload using Postman, however struggling to replicate this in VB - getting the following error:
{“status”:“error”,“message”:“Invalid json Content-Disposition: form-data; name=\“options\”\r\nContent-Type: application/json\r\n{\“access\”:\“PRIVATE\”} for options string. Make sure required field \“access\” is set.”,“correlationId”:“b7a1d6b2-83c5-41b0-847a-acd007595745”}
code I’m using to POST is:
'prepare body
sPostBody = “--” & STR_BOUNDARY & vbCrLf & _
“Content-Disposition: form-data; name=”“file”“; filename=”“” & Mid$(sFileName, InStrRev(sFileName, “\”) + 1) & “”“” & vbCrLf & _
“Content-Type: application/octet-stream” & vbCrLf & _
sPostData & vbCrLf & _
“--” & STR_BOUNDARY & vbCrLf & _
“Content-Disposition: form-data; name=”“folderPath”“” & vbCrLf & _
“Quotes” & vbCrLf & _
“--” & STR_BOUNDARY & vbCrLf & _
“Content-Disposition: form-data; name=”“options”“” & vbCrLf & _
“Content-Type: application/json” & vbCrLf & _
“{”“access”“:”“PRIVATE”“}” & vbCrLf & _
“--” & STR_BOUNDARY & “--”
'post
With CreateObject(“Msxml2.ServerXMLHTTP.6.0”)
.Open “POST”, sUrl, bAsync
.setRequestHeader “Content-Type”, “multipart/form-data; boundary=” & STR_BOUNDARY
.setRequestHeader “Authorization”, sAuth
.send pvToByteArray(sPostBody)
Please note I am not programmer so is quite possible I am missing something very basic - any help appreciated.
Thanks
Nick