I'm using the BullionVault API to view my orders.
I have to be logged in to view it.
My issue is that when I try to login with an HTTP request, my console output is the HTML DOM of the BUllionVault login page.
I use the requests from the official documentation https://www.bullionvault.com/help/xml_api.html and python language.
My request to login :
payload2 = {'j_username': 'myusername', 'j_password': 'mypassword'}
requests.get("https://or.bullionvault.fr/secure/login.do", params=payload2)
My request to view my orders :
requests.get("https://or.bullionvault.fr/secure/view_orders_xml.do")
EDIT :
Thanks to @Vikas I updated my code.
login_page_url = "https://or.bullionvault.fr/secure/login.do"
login_page_url2 = "https://live.bullionvault.com/secure/j_security_check"
payload2 = {'j_username': 'myusername', 'j_password': 'mypassword'}
with requests.Session() as s:
a = s.get(login_page_url)
print(s.cookies)
b = s.get(login_page_url2, params = payload2)
c = s.get("https://or.bullionvault.fr/secure/view_orders_xml.do")
print(a) #output status 200
print(b) #output status 200
print(c) #output status 200
print(c.text) #output HTML DOM
However I still have my issue : last request response is the HTML DOM of the login page.
SOLUTION :
Bullionvault updated its API to version 2.0. There were also parameters missing in my code.
login_page_url = "https://or.bullionvault.fr/secure/login.do"
login_page_url2 = "https://live.bullionvault.com/secure/j_security_check"
payload2 = {'j_username': 'myusername', 'j_password': 'mypassword'}
payload3 = {'confirmed': 'true'}
payload4 = {'simple': 'true'}
with requests.Session() as s:
a = s.get(login_page_url)
b = s.post(login_page_url2, data = payload2)
c = s.get("https://live.bullionvault.com/secure/api/v2/view_orders_xml.do", params = payload3)
d = s.get("https://live.bullionvault.com/secure/api/v2/view_balance_xml.do", params = payload4)