Is it possible to POST an image (e.g., image/jpeg) with system.net.httpPost? There does not seem to be a way to send binary data (only String). If this is not the appropriate function, what is the best way to POST images from Ignition?
Do you have control of the server side that handles accepting the POST request?
You could use the base64 module or some other serialization format to encode the image file and then post it as text then decode on the server side.
It’s a standard installation of JIRA. I am trying to upload an image to their REST API. I have tried serializing to base64 but that does not seem to work with JIRA.
In that case you may need to import httplib and build out a more complex POST submission.
In particular, it looks like JIRA might require not only the file attached as multipart/formdata, but also a custom header(X-Atlassian-Token: no-check) to prevent XSRF attacks.
Thanks for the reply. I ended up using javax.net.ssl.HttpsURLConnection to write multipart/form-data. httplib did not seem to like TLS 1.2. Not easy, but I did eventually get it to work using this as reference:
Jira also required that Content-Disposition: form-data; name=“file” for some reason, which tripped me up for a bit.
Any chance you’d like to share your code for this? I’m looking to post documents to Telegram and this seems like the direction I need to go.