# POST Image with system.net.httpPost

**URL:** <https://forum.inductiveautomation.com/t/post-image-with-system-net-httppost/17393>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [March 16, 2018, 3:20pm UTC](https://forum.inductiveautomation.com/t/post-image-with-system-net-httppost/17393 "2018-03-16T15:20:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![atran](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@atran](https://forum.inductiveautomation.com/u/atran)\
**Post date:** [March 16, 2018, 3:20pm UTC](https://forum.inductiveautomation.com/t/post-image-with-system-net-httppost/17393/1 "2018-03-16T15:20:03Z")

</div>

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?

Thanks,

Adam

---

<div class="post-metadata">

**Author:** ![phillip.bow](https://avatars.discourse-cdn.com/v4/letter/p/ce73a5/32.png) [@phillip.bow](https://forum.inductiveautomation.com/u/phillip.bow)\
**Post date:** [March 16, 2018, 4:00pm UTC](https://forum.inductiveautomation.com/t/post-image-with-system-net-httppost/17393/2 "2018-03-16T16:00:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![atran](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@atran](https://forum.inductiveautomation.com/u/atran)\
**Post date:** [March 16, 2018, 7:24pm UTC](https://forum.inductiveautomation.com/t/post-image-with-system-net-httppost/17393/3 "2018-03-16T19:24:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![phillip.bow](https://avatars.discourse-cdn.com/v4/letter/p/ce73a5/32.png) [@phillip.bow](https://forum.inductiveautomation.com/u/phillip.bow)\
**Post date:** [March 16, 2018, 7:51pm UTC](https://forum.inductiveautomation.com/t/post-image-with-system-net-httppost/17393/4 "2018-03-16T19:51:17Z")

</div>

In that case you may need to import httplib and build out a more complex POST submission.

[https://docs.python.org/2/library/httplib.html](https://docs.python.org/2/library/httplib.html)  
[http://mattshaw.org/news/multi-part-form-post-with-files-in-python/](http://mattshaw.org/news/multi-part-form-post-with-files-in-python/)

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.

---

<div class="post-metadata">

**Author:** ![atran](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@atran](https://forum.inductiveautomation.com/u/atran)\
**Post date:** [March 19, 2018, 2:55pm UTC](https://forum.inductiveautomation.com/t/post-image-with-system-net-httppost/17393/5 "2018-03-19T14:55:08Z")

</div>

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:

[https://stackoverflow.com/questions/11766878/sending-files-using-post-with-httpurlconnection](https://stackoverflow.com/questions/11766878/sending-files-using-post-with-httpurlconnection)

Jira also required that Content-Disposition: form-data; name=“ **file** ” for some reason, which tripped me up for a bit.

---

<div class="post-metadata">

**Author:** ![ctonge](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@ctonge](https://forum.inductiveautomation.com/u/ctonge)\
**Post date:** [June 5, 2018, 9:26pm UTC](https://forum.inductiveautomation.com/t/post-image-with-system-net-httppost/17393/6 "2018-06-05T21:26:24Z")

</div>

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.

Thanks!
