You need to sign in to do that
Don't have an account?
Ayub Ansari
Query with where clause in Tooling API not working
Hi,
I am trying to access metadata of Profile by using tooling api, when I request query without adding any filter as given below, I am getting response as expected:
string epoint = 'https://ap1.salesforce.com/services/data/v32.0/tooling/query?q=SELECT+Description,+Name,+Metadata,+FullName+FROM+Profile';
But, as I am adding a filter as below, I am getting error- "Bad Request" Status Code= 400. Please note that this query executes as expected in developer console--> Query Editor, but throw specified error when trying to execute apex code in anonymous block.
String epoint = 'https://ap1.salesforce.com/services/data/v32.0/tooling/query?q=SELECT+Description,+Name,+Metadata,+FullName+FROM+Profile+where+Name=\''+'System Administrator'+'\'';
I have already posted this question on developer forum. Any help would be greatly appreciated.
Thanks,
-Ayub
I am trying to access metadata of Profile by using tooling api, when I request query without adding any filter as given below, I am getting response as expected:
string epoint = 'https://ap1.salesforce.com/services/data/v32.0/tooling/query?q=SELECT+Description,+Name,+Metadata,+FullName+FROM+Profile';
But, as I am adding a filter as below, I am getting error- "Bad Request" Status Code= 400. Please note that this query executes as expected in developer console--> Query Editor, but throw specified error when trying to execute apex code in anonymous block.
String epoint = 'https://ap1.salesforce.com/services/data/v32.0/tooling/query?q=SELECT+Description,+Name,+Metadata,+FullName+FROM+Profile+where+Name=\''+'System Administrator'+'\'';
I have already posted this question on developer forum. Any help would be greatly appreciated.
Thanks,
-Ayub
As I told- its working on query editor and workbench as expected. Did you execute ?
It will throw exception "string literal not allowed".
I solved the issue myself- basically issue was very simple related to encoding- while making request- I was passing filter value 'System Administrator' but I shoud pass an encoded value like this- 'System+Administrator'.
Thank you Amit once more!
-Ayub.
All Answers
I tested the same in workbanch it working fine for me:-
Please try below Code:-
Please mark this as solution if this will help you
Thanks
Amit Chaudhary
As I told- its working on query editor and workbench as expected. Did you execute ?
It will throw exception "string literal not allowed".
I solved the issue myself- basically issue was very simple related to encoding- while making request- I was passing filter value 'System Administrator' but I shoud pass an encoded value like this- 'System+Administrator'.
Thank you Amit once more!
-Ayub.