How to pass filter param as query string for GET

Environment: C#  (asp.net 2.0 framework), REST V10.

since passing parameter as body is not supported in WebRequest for GET method, I am try to pass parameters as query string. I can successfully pass order_by, fields and other parameters But not successful with filter (expression) parameter.

code sample:

WebRequest wRequest = WebRequest.Create(sBaseURL + "/Accounts?filter={\"filter\":[{\"name\":\"DENALI\"}]}&fields=id,name,start_rr_c&max_num=1000&view=record");

Am I doing something wrong? any help is really appreciated. Thanks in Advance

Thanks

Rama

Parents
  • Hi Rama Reddy,

    The URL you are trying to pass in order for the filter to work is bad formed.

    The URL should be like the following:

    http://<base URL>/Accounts/filter?filter[0][name]=DENALI&fields=id,name,start_rr_c&max_num=1000

    If you wanted to get all the accounts whose name starts by DENALI it should be like this:

    http://<base URL>/Accounts/filter?filter[0][name][$starts]=DENALI&fields=id,name,start_rr_c&max_num=1000

    And if you want to filter your result according to more complex logic you should try something like this:

    http://<base URL>/Accounts/filter?filter[0][$and][0][name]=DENALI&filter[0][$and][1][email1]=test@denali.com&fields=id,name,start_rr_c&max_num=1000

    In this last one what I am doing is to get all the accounts whose name is DENALI and email is test@denali.com.

    Let me know if you need further help with this.

    Hope it helps!

    Regards,


    David.

Reply
  • Hi Rama Reddy,

    The URL you are trying to pass in order for the filter to work is bad formed.

    The URL should be like the following:

    http://<base URL>/Accounts/filter?filter[0][name]=DENALI&fields=id,name,start_rr_c&max_num=1000

    If you wanted to get all the accounts whose name starts by DENALI it should be like this:

    http://<base URL>/Accounts/filter?filter[0][name][$starts]=DENALI&fields=id,name,start_rr_c&max_num=1000

    And if you want to filter your result according to more complex logic you should try something like this:

    http://<base URL>/Accounts/filter?filter[0][$and][0][name]=DENALI&filter[0][$and][1][email1]=test@denali.com&fields=id,name,start_rr_c&max_num=1000

    In this last one what I am doing is to get all the accounts whose name is DENALI and email is test@denali.com.

    Let me know if you need further help with this.

    Hope it helps!

    Regards,


    David.

Children