I am having trouble figuring out how to PUT a file to an API with CURL using a URLConnection. I have several API methods working using GET,POST and DELETE. But I am stuck on everything that involves PUT and uploading a file.
This is the CURL that I’m having trouble with:
Var f As FolderItem
f = New FolderItem(“E:\Xojo Projects 2023\images\Xnavigator\XwindowsOrb256 - Copy.png”, FolderItem.PathModes.Native)
Var json As New JSONItem
Typically, a PUT tells the server to store the included entity at the given path. You would not use multiport with PUT. Read the contents of the folderitem, then use SetRequestContent to those contents with the correct content type. So if the file were a PNG, you would use image/png. The API might let you get away with application/octet-stream, which basically means “it could be anything.”
Also, you only ever need one SetRequestContent per request. The second call will replace the contents set in the first.
Thanks. I noticed I had two SetRequestContent’s in there as I was sitting here studying my code and was waiting for someone to say something That was me trying anything and everything to get it to work as I got frustrated. I’ll give those suggestions a try and will post the results.