You need to sign in to do that
Don't have an account?
Setting Cookie Header in HTTP callout
Hello,
I am using below code for setting Cookie in HTTP callout , Looks like its not working.
Is my code correct?
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setHeader('Cookie', 'Name=Value');
Regards,
Sushil
I am using below code for setting Cookie in HTTP callout , Looks like its not working.
Is my code correct?
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setHeader('Cookie', 'Name=Value');
Regards,
Sushil
In order to set HTTP headers, add inputHttpHeaders_x and outputHttpHeaders_x to the stub.
Here's an example that sets input HTTP Headers:
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.inputHttpHeaders_x = new Map<String, String>();
//Setting a basic authentication header
stub.inputHttpHeaders_x.put('Authorization', 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==');
//Setting a cookie header
stub.inputHttpHeaders_x.put('Cookie', 'name=value');
where stub is included in the apex class included in the Apex class generated from the WSDL document for calling the third-party Web service represented by the WSDL document.
You can modify the above code example as per your requirement. Hope this helps you to get the working code.