You need to sign in to do that
Don't have an account?
AkashGarg555
"message":"INVALID_HEADER_TYPE","errorCode":"INVALID_AUTH_HEADER"
Hi,
I'm trying to fetch the data of one salesforce Org to another through HTTP request method.
I'm able to fetch the session ID but when i'm using this Session ID it give me error of "message":"INVALID_HEADER_TYPE","errorCode":"INVALID_AUTH_HEADER".
Can anyone help as this is very urgent.
I'm trying to fetch the data of one salesforce Org to another through HTTP request method.
I'm able to fetch the session ID but when i'm using this Session ID it give me error of "message":"INVALID_HEADER_TYPE","errorCode":"INVALID_AUTH_HEADER".
Can anyone help as this is very urgent.
public with sharing class AuthCallout { public static string getOrgSessionId(string orgICIXId) { HttpRequest req = new HttpRequest(); String content = UserInfo.getOrganizationId() + '.' + DateTime.now().formatGMT('yyyy-MM-dd\'T\'HH:mm:ss.S\'Z\''); String signature = EncodingUtil.base64Encode(Blob.valueOf(content)) + '.' + EncodingUtil.base64Encode(Crypto.generateMac('HmacSHA256', Blob.valueOf(content), Blob.valueOf( UserInfo.getOrganizationId() ))); req.setEndpoint('https://staging-concateno.herokuapp.com/util/session-id/' + orgICIXId); req.setMethod('GET'); req.setHeader('Authorization', signature); req.setHeader('Content-Type', 'application/json'); Http http = new Http(); HTTPResponse res = http.send(req); System.debug(res.getBody()); return res.getBody(); } public static string getData() { string orgSessionId = getOrgSessionId('304736'); string workflowGlobalId = '304736'; string queryToRun = 'SELECT Id, Name FROM BR1DevStgRes__Workflow_Instance__c WHERE BR1DevStgRes__Global_Id__c='+workflowGlobalId; system.debug('orgSessionId : '+orgSessionId); system.debug('queryToRun : '+queryToRun); HttpRequest req1 = new HttpRequest(); req1.setEndpoint('https://na85.salesforce.com/services/data/v38.0/query/?q=' + EncodingUtil.urlEncode(queryToRun, 'utf-8') ); req1.setMethod('GET'); req1.setHeader('Authorization', 'OAuth '+orgSessionId); req1.setHeader('Content-Type', 'application/json'); Http http1 = new Http(); HTTPResponse res = http1.send(req1); System.debug(res.getBody()); return res.getBody(); } }