Making an Authenticated HTTP Request

Asked by Alex Ezell

Is there a method through which I can request a Salesforce URL using the authenticated session/connection which has already been created?

What I am trying to do is to make a request to Salesforce which returns XML. This particular XML is undocumented, so it is not accessible via the API, only via a URL through HTTP.

Question information

Language:
English Edit question
Status:
Solved
For:
pyax Edit question
Assignee:
No assignee Edit question
Solved by:
Kevin Shuk
Solved:
Last query:
Last reply:
Revision history for this message
Best Kevin Shuk (surf) said :
#1

What you'd have to do is to get the session_id property from the authenticated Connection instance, build a cookie with it using Python's cookielib, then use this cookie to make the authenticated HTTP(S) calls that you need by putting the cookie into a CookieJar object set as the HTTPCookieProcessor for the urllib opener used to open your URLs.

Revision history for this message
Alex Ezell (aezell) said :
#2

Thanks surfous, that solved my question.

Revision history for this message
Alex Ezell (aezell) said :
#3

Should anyone else need to do this, I have code to share, though it's pretty straight forward once you learn how to use the CookieJar, like I learned =)