How do you encode spaces in a query with a filter?

Oct 23, 2009 at 8:22 PM

The following query with a filter works when issued from a browser

          Customer(customerId='VE1')/orders?$filter=orderDate ge datetime'2009-10-16T00:00:00' and orderDate le datetime'2009-10-20T23:59:59.99'

When I attempt to execute it programatically, it fails.

          $rangeResult = $proxy->ExecuteQuery("Customer(customerId='$customerId')/orders?\$filter=orderDate ge datetime'$lowDate' and orderDate le datetime'$hiDate'");

The spaces were turned into + signs.

          Customer(customerId='VE1')/orders?$filter=orderDate+ge+datetime%272009-10-17T%3A00%3A00%3A00%27+and+orderDate+le+datetime%272009-10-21T%3A23%3A59%3A99%27

When I try substituting the spaces with %20 it also fails, the %20 gets turned into %2520

          $rangeResult = $proxy->ExecuteQuery"Customer(customerId='$customerId')/orders?\$filter=orderDate%20ge%20datetime'$lowDate'%20and%20orderDate%20le%20datetime'$hiDate'");

          Customer(customerId='VE1')/orders?$filter=orderDate%2520ge%2520datetime%272009-10-17T%3A00%3A00%3A00%27%2520and%2520orderDate%2520le%2520datetime%272009-10-21T%3A23%3A59%3A99%27