+ Start a Discussion
pavan bommana 5pavan bommana 5 

Not able to create a userstory in rally through basic authentication in rest api

I am able to create a userstory with this api in POSTMAN but it is showing error in apex class.
public class rallyIntegrate {
    public string variable;
    public string securityToken;
    public void getSourcetoken(){
       HTTP h = new HTTP();
        HTTPRequest r = new HTTPRequest();        
        Blob headerValue = Blob.valueOf(UserName+ ':' +Password );
        String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        r.setHeader('Authorization', authorizationHeader);
        HTTPResponse resp = h.send(r);
        variable = resp.getBody();
        system.debug('===+++'+variable.substringAfter('OperationResult').substringBetween('SecurityToken": "','"}}')); 
         securityToken = variable.substringAfter('OperationResult').substringBetween('SecurityToken": "','"}}');
    public void getSourceBody(){
        string body = '{"HierarchicalRequirement":{"Name":"Rally full Test","Description":"Created my second user story"}}';
        HTTP htt = new HTTP();
        HTTPRequest req = new HTTPRequest(); 
        req.setHeader('Content-Type', 'application/json');
        HTTPResponse res = htt.send(req);
        system.debug('response++  '+res.getBody());

ERROR : Full authentication is required to access this resource.
Can anyone help me in this please.
SwethaSwetha (Salesforce Developers) 
HI Pavan,
Can you check if you are running behind a proxy? Have you ensured that the Salesforce IP ranges mentioned in https://help.salesforce.com/articleView?id=000321501&type=1&mode=1 are whitelisted at your Third party?

Related: https://github.com/jenkinsci/rally-plugin/issues/15

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you