I'm making a SF org where i need to retrieve data from a 2nd SF org. I have created Connected App in my Source Org, and i have created Auth. Provider and Named Credential in the Portal Org (that the users are gonna use).
In the Portal Org, i have this Apex code:
public with sharing class AuthCallout {
public static Http http = new Http();
public static HTTPResponse response;
public static HttpRequest request;
public static void getContact(Id conId) {
request = new HttpRequest();
request.setMethod('GET');
request.setEndpoint('callout:DataOrgAPI/services/apexrest/Contact/' + conId);
response = http.send(request);
System.debug(response.getBody());
}
The Data Org has this Apex Code:
@RestResource(urlMapping='/Contact/*')
global with sharing class ContactAPI {
@HttpGet
global static Contact doGet() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String conId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Contact result = [SELECT Id, Name FROM Contact WHERE Id = :conId];
return result;
}
}
To test to see if i can find the data in the Source Org, I've tried to run this in Anonymous Window.
AuthCallout.getContact('0037S00000CF66fQAD');
Currently getting StatusCode 302 Code in the response.
But I'm not able to find Contacts in the Data Org, only in my Portal Org. I also retrieve nothing from response.getBody().
Any ideas on how i can find the values in the Data Org?