I’m trying to do a doPost and I’m following the example linked below, but I’m getting a weird error:
Server returned HTTP response code: 500 for URL: http://localhost:8088/system/webdev/arduino_project/postjson
Can anyone help me with this?
The example:
https://docs.inductiveautomation.com/display/DOC80/httpPost
This is the code for my doPost:
data = request['postData']
names = data['names']
values = data['values']
# this will print to the wrapper.log file
print names, values
# format the string into HTML
formattedString = "<html><body>"
# loop through and add names and values
for i in range(len(names)):
formattedString += "%s: %s, " %(names[i], values[i])
# remove the last ', ' and add closing html
formattedString = formattedString[:-2]+"</body></html>"
# this will print to the wrapper.log file
print formattedString
# return the value string
return {'html': formattedString}
This is the code for my button:
projectName = "arduino_project"
doPostName = "postjson"
url = "http://localhost:8088/system/webdev/arduino_project/postjson"
# create the dictionary of parameters to pass in
params = {}
params['names'] = ['String','Integer']
params['values'] = ['Hello World', 42]
# encode dictionary to JSON
jsonParams = system.util.jsonEncode(params)
# post to Ignition
postReturn = system.net.httpPost(url, jsonParams)
# print return value
print postReturn
I appreciate any help!