function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Keith Stephens 18Keith Stephens 18 

get info from query for a case

I am calling Salesforce query api call, and I am wanting to pass in a case id, but it is not working.
I have tried to add single quotes around the ID but that did ot work either.
If I remove the where clause it works just fine.
Any help would be appritiated.
Thanks,
Keith.
 
String url = 'https://test.salesforce.com/services/data/v40.0/query?q=SELECT+Plaintiff_First_Name__c,Plaintiff_Last_Name__c,Attorney_Fax__c,Attorney_First_Name__c,Attorney_Last_Name__c+FROM+Case+WHERE+Id=500g000000G1DB4';
system.debug(url);
Http h = new Http();
HttpRequest req = new HttpRequest();
system.debug('got request');
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
req.setHeader('Content-Type', 'application/json');
req.setEndpoint(url);
system.debug('setendpoint');
req.setMethod('GET');
HttpResponse res = h.send(req);


 
Best Answer chosen by Keith Stephens 18
Alain CabonAlain Cabon
Just escape the simple quotes.
String url = 'https://test.salesforce.com/services/data/v40.0/query?q=SELECT+Plaintiff_First_Name__c,Plaintiff_Last_Name__c,Attorney_Fax__c,Attorney_First_Name__c,Attorney_Last_Name__c+FROM+Case+WHERE+Id=\'500g000000G1DB4\'';
system.debug(url);

All Answers

Alain CabonAlain Cabon
Just escape the simple quotes.
String url = 'https://test.salesforce.com/services/data/v40.0/query?q=SELECT+Plaintiff_First_Name__c,Plaintiff_Last_Name__c,Attorney_Fax__c,Attorney_First_Name__c,Attorney_Last_Name__c+FROM+Case+WHERE+Id=\'500g000000G1DB4\'';
system.debug(url);
This was selected as the best answer
Keith Stephens 18Keith Stephens 18
Thanks.