bramton / degiro

Very basic unofficial Python API for DeGiro

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue while running the script

ghust opened this issue · comments

commented

Hey Bram,

I reinstalled a computer and now wanted to add my "log degiro portfolio"-cronjob again.
However, after installing python and requests, I get the following when running:

<Response [200]>
Account id: whatever
Get data
Status code: 401
Traceback (most recent call last):
File "test.py", line 7, in
pfs = la.getPortfolioSummary()
File "/home/osmc/python/pyscripts/degiro.py", line 88, in getPortfolioSummary
pf = self.getPortfolio()
File "/home/osmc/python/pyscripts/degiro.py", line 102, in getPortfolio
self.getData()
File "/home/osmc/python/pyscripts/degiro.py", line 68, in getData
self.data = r.json()
File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.5/json/init.py", line 319, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)


Any pointers? Cheers :)

commented
<title>Apache Tomcat/7.0.64 - Error report</title><style></style>

HTTP Status 401 -


type Status report

message

description This request requires HTTP authentication.


Apache Tomcat/7.0.64

This is the response.text

Hmmmm, now I need to see if it's only at my end

commented

I just checked on my own computer and the API still works fine. I'm sorry I can't be of any help, but let me know anyway when you found the issue, just out of curiosity.

commented

looks like it happens here:

` url += str(self.user['intAccount'])+';'
url += 'jsessionid='+self.sessid
print(url)
payload = {'portfolio': 0,
'totalPortfolio': 0,
'orders': 0,
'historicalOrders': 0,
'transactions': 0,
'alerts': 0,
'cashFunds': 0,
'intAccount': self.user['intAccount'],
'sessionId': self.sessid}

    r = self.sess.get(url, params=payload)
    print(payload)
    print('Get data')
    print('\tStatus code: {}'.format(r.status_code))`

(I added some prints for debugging).

It adds the intaccount and the sessionid, however degiro hits me with a 401 "this request requires http authentication".

Strange, I'm a bit lost atm :)

commented

Do you have a .staging2 sessionid?
You're also going to for the getData() function? https://trader.degiro.nl/trading/secure/v5/update/xxxxxx;jsessionid=ichangedthis.staging2

commented

That's interesting. I don't have .staging2 sessionid in the URL. Wel spotted !
My URL for retreiving data looks as follows:
https://trader.degiro.nl/trading/secure/v5/update/xxxxxxx;jsessionid=ichangedthis.prod6

Do you have a free DeGiro account or a payed one ? What happens if you modify the code to replace staging2 with prod6 ?.