# Strange IO error from httpPut

**URL:** <https://forum.inductiveautomation.com/t/strange-io-error-from-httpput/55748>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [February 4, 2022, 8:32am UTC](https://forum.inductiveautomation.com/t/strange-io-error-from-httpput/55748 "2022-02-04T08:32:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff.li](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jeff.li/32/68813_2.png) [@jeff.li](https://forum.inductiveautomation.com/u/jeff.li)\
**Post date:** [February 4, 2022, 8:32am UTC](https://forum.inductiveautomation.com/t/strange-io-error-from-httpput/55748/1 "2022-02-04T08:32:41Z")

</div>

Hi, All

I face a strange issue when I try to use system.net.httpPut, I use exactly same code in script console, it runs well, no any issue, but when I put it into tag value changed event, it will return IO error

the code is like this:

```auto
from urllib2 import URLError, HTTPError
apiKey = 'xxxx-xxxxx-xx'
Type = 'application/json'
header = {
		'appKey': '%s' %apiKey
		}
data = '{"Partnumber":"TestPart_N1"}'
fullurl = 'http://myaddress:8080/Properties/Partnumber'
try:
	updateValue = system.net.httpPut(fullurl,Type,data,60000,60000,'','',header)
	response = {'success':True,'response':updateValue.encode('utf-8')}
except HTTPError, he:
	response = {'success':False,'HTTPError':he, 'url':fullurl, 'putData':data}
except URLError, ue:
	response = {'success':False,'URLError':ue, 'url':fullurl, 'putData':data}
except IOError, ioe:
	response = {'success':False,'IOError':ioe, 'url':fullurl, 'putData':data}
except:
	response = {'success':False,'otherException':'Timeout', 'url':fullurl, 'putData':data}
print (str(response))

```

when I run it in the script console, it returns: {‘success’: True, ‘response’: ‘’}

but when I try it in the tag value changed event, it returns:  
{‘url’: u’[http://myaddress:8080/Properties/Partnumber](http://myaddress:8080/Properties/Partnumber)’, ‘IOError’: IOError(‘Server returned HTTP response code: 503 for URL: [http://www.myaddress.com/Properties/Partnumber](http://www.myaddress.com/Properties/Partnumber)’,), ‘success’: False, ‘putData’: ‘{“Partnumber”:“TestPart\_N1”}’}

the strange thing is here, in the fullurl, I try to connect to [http://myaddress:8080](http://myaddress:8080), but in the IO error message, it shows code 503 and URL changed to [http://www.myaddress.com](http://www.myaddress.com), which is not I want to connect to, any idea about this?

thanks in advance

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [February 4, 2022, 2:38pm UTC](https://forum.inductiveautomation.com/t/strange-io-error-from-httpput/55748/2 "2022-02-04T14:38:05Z")

</div>

I’ve seen this type of behavior in browsers before when a given name doesn’t resolve (it will try prefixing with “www.”). Are you running the Designer on the same machine as the gateway? Assuming that is the case, the name resolution will be different when run in a [gateway] tag script. I’d check to see if `myaddress` is able to resolve on the gateway machine (via `nslookup myaddress`).

---

<div class="post-metadata">

**Author:** ![jeff.li](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jeff.li/32/68813_2.png) [@jeff.li](https://forum.inductiveautomation.com/u/jeff.li)\
**Post date:** [February 5, 2022, 2:19am UTC](https://forum.inductiveautomation.com/t/strange-io-error-from-httpput/55748/3 "2022-02-05T02:19:43Z")

</div>

Thanks @kcollins, I tried both, our gateway running on a dedicated server, I have tried running designer on my laptop and server both side, same result, and from gateway server, nslookup and browser both can return the correct response, so that’s the strange point

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [February 5, 2022, 3:29pm UTC](https://forum.inductiveautomation.com/t/strange-io-error-from-httpput/55748/4 "2022-02-05T15:29:36Z")

</div>

You might try the equivalent implementation with [system.net.httpClient](https://docs.inductiveautomation.com/display/DOC81/system.net.httpClient) and see if you get any difference in behavior.

---

<div class="post-metadata">

**Author:** ![jeff.li](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jeff.li/32/68813_2.png) [@jeff.li](https://forum.inductiveautomation.com/u/jeff.li)\
**Post date:** [February 6, 2022, 5:38am UTC](https://forum.inductiveautomation.com/t/strange-io-error-from-httpput/55748/5 "2022-02-06T05:38:58Z")

</div>

have tried httpClient, not same result, but similar, I use it like this:

```auto
Client = system.net.httpClient()
response = Client.put(url=fullurl,data=data, headers=header)

```

from script console, I got statusCode 200, in tag event, I got statusCode 307, if I add redirect\_policy then the code will be 503

so really don’t know what happens here, only can working is call httplib and use request feature

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 6, 2022, 10:20am UTC](https://forum.inductiveautomation.com/t/strange-io-error-from-httpput/55748/6 "2022-02-06T10:20:01Z")

</div>

Tip: There’s a `</>` code formatting button on the editor toolbar. Select your code and click the button and it will format properly with indents. There’s a 'pencil` edit button below your post. I recommend that you capitalise and punctuate your posts properly for legibility and to avoid detracting from the content. Your compiler wouldn’t let you away with it!

---

<div class="post-metadata">

**Author:** ![pascal.meulenkamp](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.meulenkamp/32/55038_2.png) [@pascal.meulenkamp](https://forum.inductiveautomation.com/u/pascal.meulenkamp)\
**Post date:** [February 3, 2023, 3:19pm UTC](https://forum.inductiveautomation.com/t/strange-io-error-from-httpput/55748/7 "2023-02-03T15:19:27Z")

</div>

Did you even get this to work? I'm experiencing the same issue, everything works fine from the script editor, but when run from the gateway (tag change script) I get an IO error.
