0

Can anyone tell me how to set the Authorization Header in Apex callout? I get the Error message "Unknown authorization header" when connect to Linked in.. My authorization header as follows

    string TripItAccessDataUri='https://api.linkedin.com/v1/people/';

    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setMethod('GET');
    req.setEndpoint(TripItAccessDataUri);

    Blob headerValue = Blob.valueOf(oauth_consumer_key+':'+oauth_token+':'+oauth_nonce+':'+oauth_token_secret+':'+oauth_signature_method+':'+oauth_timestamp+':'+oauth_version);
    String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
    req.setHeader('Authorization', authorizationHeader);

    HttpResponse res = h.send(req);
    string resData =  res.getBody();
    system.debug(' Respose' + resData );
  • req.setHeader('Content-Type', 'text/xml'); req.setHeader('Authorization', aToken); where aToken is the Authorization token . Try setting Content Type explicitly and check . If it is not working , then it simply means that the Web Service at the other end does not have the Auth key as "Authorization" . Just check the webservice at the other end too . – TroubleShooter Oct 16 '14 at 7:52
  • @TroubleShooter: Where I have to check the content type ? please give me the link to check the content type – user3332076 Oct 17 '14 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.