I am going slightly mad...
Any pointers in the right direction is very appreciated thank you in advance.
I am very very new to both Python and Plex - but I have some 35 years of programming experience, less than one month with Plex and Python..
I have a webservice (that I call, not mine) it ask for a URL encoded as follows - I have tried any variant, the order does not matter but apart from that the single element do.
index.php?abc=x&def=y&ghi=z&jkl={"id":0,"type":"xyz"}
if I type that into a browser I get a great result back, so at least verified as a valid URL
When I try this :
URL = 'http://domain.tld/'
def MyFunction(title, avalue):
oc = ObjectContainer(title2=title)
data = {‘id’:0,‘type’:‘thetype’}
data[‘id’] = avalue
post_values = ‘abc=x&def=y&ghi=z&jkl=’ + data
Log.Info('values : '+ post_values)
I get wrong value in post_values, I get : INFO (logkit:16) - values : abc=x&def=y&ghi=z&jkl=id=0&type=thetype
This result in a wrong return from the server (empty response).
Then I tried to "think out of the box" and constructed this guy :
post_values = 'abc=x&def=y&ghi=z&jkl={"id":' + avalue + ',"type":"thetype"}'
And my logstring looks like this :
INFO (logkit:16) - values : abc=x&def=y&ghi=z&jkl={"id":7,"type":"thetype"}
Everything should be fine then, just send it to the server and get a reasonable answer back, but I am a bit out of luck here...
I try both HTTP.Request(URL, post_values) and JSON.ObjectFromURL(URL, post_values) the only response I get is : "This channel is not responding." and logfile message (it is fun but not very helpfull) :
handle_request
result = f(**d)
And then I get : TypeError: not a valid non-string sequence or mapping object
I am pretty sure the {} part is the problem, but I need, as I write, the URL to be encoded as such to get a result back, no option to change anything there...
Any help to point me to resourses or if you now make a "PalmToFace" thinking : How stupid is it humanly possible to get, and have a clear simple suggestion I would be very grateful.
Thank You in advance.