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:
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’, ‘IOError’: IOError(‘Server returned HTTP response code: 503 for URL: 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, but in the IO error message, it shows code 503 and URL changed to http://www.myaddress.com, which is not I want to connect to, any idea about this?
thanks in advance