Forum Discussion

nonenonenone123's avatar
nonenonenone123
Icon for Nimbostratus rankNimbostratus
Oct 23, 2015

iControl REST $filter processing not HTTP compliant?

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?

 

6 Replies

  • 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')

    • nonenonenone123's avatar
      nonenonenone123
      Icon for Nimbostratus rankNimbostratus
      That is indeed really unpleasant. Do you know if this is a known limitation, bug, or similar?
    • Brad_Parker's avatar
      Brad_Parker
      Icon for Cirrus rankCirrus
      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.
  • 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')

    • nonenonenone123's avatar
      nonenonenone123
      Icon for Nimbostratus rankNimbostratus
      That is indeed really unpleasant. Do you know if this is a known limitation, bug, or similar?
    • Brad_Parker_139's avatar
      Brad_Parker_139
      Icon for Nacreous rankNacreous
      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.