Headers and Cookies not set on Page Reference when URL references to an external domain

695 views Asked by At

I have a problem setting headers and cookies on Page Reference object in Salesforce. Below is the APEX code I use:

PageReference page = new PageReference('https://mysystem.com/service');
page.getHeaders().put('Authorization', authorizationHeader);  
Cookie cookie = new Cookie('TestName', 'TestValue', '/', -1, false);
List<Cookie> c=new List<Cookie>();
c.add(cookie);
page.setCookies(c);

This code performs a GET HTTP Request to 'https://mysystem.com/service' without setting any header or cookies. It seems that the parameter disappears. Anyone know what's the problem there?

Moreover is it possible to do a basic authentication to a NON-salesforce domain system using Page Reference objects?

0

There are 0 answers