You need to sign in to do that
Don't have an account?
Acccessing SFDC report via httprequest redirecting to login page
Below is my c# code to access a salesforce report via http request and read the report output
The problem Iam having is it always redirects to sso login page, any suggestions>?
//report url
string sfdcUrl = https://test.salesforce.com/00OT00000018O9W;
//login to salesforce and creates an SFManager instance
SFManager sfdcManager = SFIntegrationManager.GetInstance();
stringsessionid = sfdcManager.sessionId;
StringBuilder sb = newStringBuilder();
// used on each read operationbyte[] buf = newbyte[8192];
// prepare the web page we will be asking for
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(sfdcUrl);
request.CookieContainer =newCookieContainer();
//set the session heaader cookie
request.CookieContainer.Add(newUri("https://test.salesforce.com/services/Soap/"),newCookie("sid", sessionid));
// execute the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// we will read data via the response streamStream
resStream = response.GetResponseStream();
string tempString = null;
intcount = 0;
do
{
// fill the buffer with data
count = resStream.Read(buf, 0, buf.Length);
// make sure we read some dataif(count != 0)
{
// translate from bytes to ASCII text
tempString = Encoding.ASCII.GetString(buf, 0, count);
// continue building the string
sb.Append(tempString);
}
}
while (count > 0); // any more data to read?
// print out page source
string retValue = sb.ToString();
return retValue;
}
Hi,
You will need to login into the Salesforce before Qurieng and pass set the session in Header.
Refer below sample code:
http://shivasoft.in/blog/salesforce/consume-salesforce-web-service-in-c-net-application/