1

I have implemented SSO among two ORGS. I have made a web services class in my service Org. Can I hit that web service from my Identity provider Org using rest callout? I tried it by making a http get request which for which I use following URL pattern (service Org Url + Urlmap to Web service class) as a response I got 302 status with updated URL, Too handle this I used following code.

while (response.getStatusCode() == 302) {
   request.setEndpoint(response.getHeader('Location'));
    System.debug('END Location isi '+response.getHeader('Location'));
    response = new Http().send(request);
} 

I was hitting this point https://cloudce-13a-dev-ed.lightning.force.com/Case/abc but it redirected to https://cloudce-13a-dev-ed.my.salesforce.com/Case

finally 404 response returns.

identigral
  • 7,543
  • 29
  • 32
  • 42
  • If I understand you correctly, it should be /services/apexrest/Case/abc. As written, I'd expect a 404 here. – sfdcfox Sep 15 '22 at 14:50
  • @sfdcfox yet after adding this to my HTTP url I am get 401 status error – nischal vasisth Sep 15 '22 at 15:15
  • SSO does not impact API calls – identigral Sep 15 '22 at 15:16
  • @identigral could you please elaborate? – nischal vasisth Sep 15 '22 at 15:17
  • They're not related to each other. For the purpose of the callout, it doesn't matter how you sign into the org. Pretend you didn't use SSO and go from there. – identigral Sep 15 '22 at 15:19
  • @identigral Is it even possible to fetch other Org Data using certificates in Salesforce. As in my scenario I do not create any connected App in my service org and I am not requesting for any authorization tokens before making http request. I am simply trying with existing certificates – nischal vasisth Sep 15 '22 at 15:23
  • Certificate-only: not possible. Without a connected app - possible but highly discouraged: https://salesforce.stackexchange.com/questions/269667/mutual-authentication-without-access-token Best practice in your scenario is use a JWT Bearer oAuth flow via Named Creds: https://salesforce.stackexchange.com/questions/269385/named-credentials-what-is-the-difference-between-jwt-jwt-token-exchange . See docs for more info. – identigral Sep 15 '22 at 15:25
  • 1
    @identigral Thanks finally it works – nischal vasisth Sep 19 '22 at 11:59

0 Answers0