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
Nitin Palmure 5Nitin Palmure 5 

Getting issue due to SSO

Hello, 

I am trying to integrate Jira to Salesforce using service rocket plugin.
I am trying to run following code in Execute Anonymous
 
final static String JIRA_ENDPOINT = JIRA_Config__c.getInstance().JIRA_Endpoint__c;
HttpRequest req1 = new HttpRequest();
req1.setEndpoint(JIRA_ENDPOINT);
req1.setHeader('Content-Type', 'application/json');
req1.setMethod('GET');

Http http1 = new Http();
HttpResponse res1 = http1.send(req1);
system.debug(req1);
system.debug(res1);
system.debug(req1);
String username='nitin.palmure@pubmatic.com';
String password='Password@123';
String location;
String endpoint;
try{
while (res1.getStatusCode() == 302) {
    location = res1.getHeader('Location');
    endpoint = location +'&os_username=' +username +'os_password' +password+;
    //req1.setEndpoint(res1.getHeader('Location'));
    //req1.setMethod('GET');
    //req1.setHeader('Content-Type', 'application/json');
    res1 = new http().send(req1);
}
    }catch(Exception ex)
        {
            System.debug(ex);
        }
system.debug(res1.getStatusCode());
System.debug(res1.getHeader('Location'));
System.debug(res1.getHeader('Set-Cookie'));

Now the problem is that System.debug(res1.getHeader('Location')); is giving me our SSO login URL and system.debug(res1.getStatusCode());
How do I handle this situation so that I can get system.debug(res1.getStatusCode()); as 200 ?

Please help.

Regards
Nitin V Palmure
Nitin Palmure 5Nitin Palmure 5
Just wanted to clarify that system.debug(res1.getStatusCode()); gives me 301.