Skip to main content
Hello All

I am new to Salesforce and Restful services.

But I currently have a c⌗ rest service running and I am able to call it from SF, but currently I am just passing in a hard coded string value.

Here is my code that I can run from the Development Console

 

String url = 'http://server/ErpApiService/api/PriceForCustomerA/10/15';

Http h = new Http();

HttpRequest req = new HttpRequest();

system.debug('got request');

req.setEndpoint(url);

system.debug('setendpoint');

req.setMethod('GET');

HttpResponse res = h.send(req);

system.debug('res' + res);

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

And this works and calls my rest service passing in a string value, but now I want to pass back some actual data from salesforce example

'SELECT LastModifiedDate,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c FROM Case limit 3';

I know I will have to change my parameter in my rest service to accept whatever SF will be passing to me.

But here I am not sure what or how to do this? Do I need to create a dictionary object, and pass that?

What do I need to do in SF to pass query results and then read them in my rest service.

Thanks for any help or advice,

Keith.

 
2 件の回答
  1. 2017年10月4日 17:06
    Hello All,

    Just as fyi what I got to work was. 

    I had to serialize my soql  my list<sobjects>

    Chage the GET to Post

    add setBody equal to my serialized List.

    Then on the C⌗ side I had to change my Get call to a Post and add async to the method.

    Then I could do string result = await Request.Content.ReadAsStringAsync();

                  

    To get my json string.
0/9000