I’m trying to get objects over iControl REST using python “requests”. The expected method would be something like:
r = requests.session()
r.get('https://tmhost/mgmt/tm/ltm/node', params={'$filter': 'name eq NODENAME'})
This fails, because requests - complying with the HTTP spec - encodes the “$” in the URL as %24, which fails; the LTM responds with:
HTTP/1.1 400 Bad Request
{"code":400,"message":"Query parameter %24filter is invalid.","errorStack":[]}
If I manually send the HTTP request using netcat, without escaping the $, this works OK.
Is there any way to use $filter with an HTTP-compliant library?
I think you will need to pass the params as a string, though its not pretty. i.e.
r.get('https://tmhost/mgmt/tm/ltm/node', params='$filter=name eq NODENAME')
I think you will need to pass the params as a string, though its not pretty. i.e.
r.get('https://tmhost/mgmt/tm/ltm/node', params='$filter=name eq NODENAME')
That is indeed really unpleasant. Do you know if this is a known limitation, bug, or similar?
That is indeed really unpleasant. Do you know if this is a known limitation, bug, or similar?
Its not a bug, its the design of the iControl REST api. I don’t know that there is a plan to allow URL encoding or not. Many frameworks are more than happy to not use URL encoding for REST.
Its not a bug, its the design of the iControl REST api. I don’t know that there is a plan to allow URL encoding or not. Many frameworks are more than happy to not use URL encoding for REST.