Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Error #8

Open
ChedidJM opened this issue Jun 9, 2020 · 0 comments
Open

JSON Error #8

ChedidJM opened this issue Jun 9, 2020 · 0 comments

Comments

@ChedidJM
Copy link

ChedidJM commented Jun 9, 2020

Hello, I am running the following code:

import requests
import json

url_base = ("https://api.developer.deutsche-boerse.com/prod/prisma-margin-estimator-2-0/2.0.0/")
api_header = {"X-DBP-APIKEY": 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'}

etd = {'line_no': 1, 'product_id': 'A2CR', 'maturity': 202112, 'net_ls_balance': 1}

results = requests.post(url_base + 'estimator',
headers = api_header,
json = {'portfolio_components':[
{'type': 'etd_portfolio', 'etd_portfolio': [etd]},
],
'clearing_currency': 'EUR'})

results.json()

print('Example of margin output:')
print(json.dumps(results['portfolio_margin'], indent=4, sort_keys=True))

The response for the post request is <Response [403]> and I get this error:

Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\simplejson\scanner.py", line 37, in _scan_once
nextchar = string[idx]
IndexError: string index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "g:\My Drive\Melanion\Jean Marc\MarginsGit\SSDF_Margins_Parser_API.py", line 52, in
results.json()
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\simplejson_init_.py", line 525, in loads
return _default_decoder.decode(s)
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\simplejson\decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\simplejson\decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\simplejson\scanner.py", line 79, in scan_once
return _scan_once(string, idx)
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\simplejson\scanner.py", line 39, in _scan_once
raise JSONDecodeError(errmsg, string, idx)
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

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

No branches or pull requests

1 participant