Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Issue while running the script #5

Open
ghust opened this issue Jan 9, 2019 · 5 comments
Open

Issue while running the script #5

ghust opened this issue Jan 9, 2019 · 5 comments

Comments

@ghust
Copy link

ghust commented Jan 9, 2019

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 :)

@ghust
Copy link
Author

ghust commented Jan 9, 2019

<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

@bramton
Copy link
Owner

bramton commented Jan 12, 2019

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.

@ghust
Copy link
Author

ghust commented Jan 13, 2019

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 :)

@ghust
Copy link
Author

ghust commented Jan 13, 2019

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

@bramton
Copy link
Owner

bramton commented Jan 17, 2019

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 ?.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants