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 

callouts rest services

Needing help to get Case information to my C# rest service.
Below is my code, but I am getting "Bad Request" error.
I am not sure what I need to do to get my query results to my service for reading.
Thanks,
KS
String Soql = 'SELECT LastModifiedDate,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c FROM Case limit 3';
List<sObject> L = Database.query(Soql);
String url = 'http://server/ErpApiService/api/PriceForCustomerB/' + L;

System.Debug(url);

Http h = new Http();
HttpRequest req = new HttpRequest();
system.debug('got request');
req.setHeader('Content-Type', 'application/json');

req.setEndpoint(url);
system.debug('setendpoint');
req.setMethod('GET');
HttpResponse res = h.send(req);

 system.debug('res' + res);
system.debug('Price: ' + res.getBody());

 
Keith Stephens 18Keith Stephens 18
FYI, I am calling this code from Development Console.
Ankita Gupta 65Ankita Gupta 65
Hi Stephens,
Did you add the api in remote site settings?
Keith Stephens 18Keith Stephens 18
Yes I did.
If I just pass back a string in the case below the number 5 it works fine, but when I try to pass my query results I get a bad request error.
String url = 'http://myserver/ErpApiService/api/PriceForCustomer/5';
 
String Soql = 'SELECT LastModifiedDate,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c FROM Case limit 3';
List<sObject> L = Database.query(Soql);
String url = 'http://server/ErpApiService/api/PriceForCustomerB/' + L;