I am trying to build a POST request to use with urlConnection. I have done quite a few of these, but never before with an attachment. In Postman I put together a request that looks like this:
Content-Type: multipart/form-data; boundary=--------------------------830792918371557810383557
Cookie: JSESSIONID=9684A4D4380F16330FDADCA4E5C56DC3
Content-Length: 207247
----------------------------830792918371557810383557
Content-Disposition: form-data; name=“file”; filename=“2007.13883.txt”
<2007.13883.txt>
----------------------------830792918371557810383557——————————————
This works fine with the api that I’m using, but I can’t work out how to reproduce this in Xojo. Specifically I can’t see where to put the boundary information that encloses the filename. The documentation is sparse on this. I saw an earlier thread from 2020 (URLConnection form data) which in turn refered back to a still earlier example using HTTPSocket. I was lost at that point.
Does anyone have an example of building a POST request that uses urlConnection and uploads a file attachment?
Any guidance on this will be gratefully received.
Thanks,
Ian.
7 posts - 4 participants