Hi all,
Would anyone have any knowledge about translating a CURL request in VBA to upload a file to my Knack application?
Below is what is demonstrated in the API & Customization wiki at https://www.knack.com/developer-documentation/#file-image-uploads.
curl -X POST "https://api.knack.com/v1/applications/YOUR-APP-ID/assets/file/upload"
\ -H 'content-type: multipart/form-data' \ -H 'x-knack-rest-api-key: YOUR-API-KEY'
\ -F "files=@/path/to/your/file.txt"
Here's what I've done so far in VBA with no success:
Sub PostFile()
Dim URL As String
Dim fileUpload As String
Dim objHTTP As New WinHttpRequest
URL = "https://api.knack.com/v1/applications/APPLICATION_ID/assets/file/upload"
objHTTP.Open "POST", URL, False
objHTTP.SetRequestHeader "X-Knack-REST-API-KEY", "API_KEY"
objHTTP.SetRequestHeader "Content-Type", "multipart/form-data"
fileUpload = "files=@\\wnsomfs01\desktops\schapman\File\inspection2.pdf"
objHTTP.Send JSONString
MsgBox (objHTTP.ResponseText)
End Sub
This currently returns the following: