How to get a URL with one parameter being a dict

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.

Excuse my limited programming knowledge, but if you are trying to call a url, should your request include the entire url without the post_value as an arguement

url_to_call = URL + post_values

http.request(url_to_call)

Thank You MovieFan - as I write I am really very new to Plex - and Python :) but you kicked me in the right direction OK :) I now get an answer (the expected) from the server

It is {"content":[{"abc":"def".....},{...},{...}], "text":""}

to me that looks like a dict with content being a list of dict 

I am trying to get one element of every dict in content...

So given my request answer is cats

I try to do :

for kittens in cats
    for paws in kittens['content']
        print paws['abc']

but that result in TypeError: string indices must be integers

I guess it is in the kittens['content'] things go a bit strange - but in my understanding of the Python types - {} denotes a dict and [] a list so I try to enter a dict get a list and, get and to get an element out of that list I would use listname['content'] but that obviously is not so :)

I have tried : 

 

for cats in dogs.iteritems():
	kittens = cats['contents']

for puppies in kittens:
print puppies[‘name’]

That does not help a lot too, I would like to get all the elements name:value pairs in the list content element

I hope this makes sense :D

Thank you again for any help

Is a dict the same as an array (an indexed variable with multiple values).  If so, then you need to use a number to call the individual enter or using the for statement should loop through each array entry and you do not need an index value.  I do not know python but in generic programming code

Array called animals has (cat, dog, pig, horse, snake)  each of these are also arrays, but remember these are the names of the array not an actual value so this will not return any type of text

Array cat has (tabby, calico, stray)

Array dog has (collie, bull dog, st bernard)

Calling animal will return the array with 5 elements in it.  To access the first element you need to use animal[1], which will return the first array.  You then use animal[1][1] to get tabby.  This is assuming the programming language lets you nest arrays.  The for statement helps by not needing the number

for creature in animals

 return creature

next

This will return each array in order (cat, dog, pig, etc).  "creature" is a temp variable name.  A second for statement lets you then access the individual elements.

for creature in animals

 for breed in creature

    print breed

next

 

The first time around animals, creature returns the array cat which is now called breed.  First time through breed then returns collie, next time returns bull dog.

I think you're looking for something like this:
# Get the data
your_url = 'http://.........'
json_obj = JSON.ObjectFromURL(your_url)

Loop over the ‘content’ list

for item in json_obj[‘content’]:

  # Get the element in the list that we want
  abc = item[‘abc’]
  Log(abc)

I think you're looking for something like this:
# Get the data
your_url = 'http://.........'
json_obj = JSON.ObjectFromURL(your_url)

Loop over the ‘content’ list

for item in json_obj[‘content’]:

  # Get the element in the list that we want
  abc = item[‘abc’]
  Log(abc)

SPOT ON - Thank you a billion...

:)