bundesAPI / bundesAPI/marktstammdaten-api

Error when running datenapi example

Open
#2 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
35
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Example from https://github.com/bundesAPI/marktstammdaten-api/blob/main/python-client/docs/DatenApi.md
```python
import time
from deutschland import marktstammdaten
from deutschland.marktstammdaten.api import daten_api
from deutschland.marktstammdaten.model.einheit_einheit_json_get_erweiterte_oeffentliche_einheit_stromerzeugung_get200_response import EinheitEinheitJsonGetErweiterteOeffentlicheEinheitStromerzeugungGet200Response
from pprint import pprint
# Defining the host is optional and defaults to https://www.marktstammdatenregister.de/MaStR
# See configuration.py for a list of all supported configuration parameters.
configuration = marktstammdaten.Configuration(
host = "https://www.marktstammdatenregister.de/MaStR"
)

# Enter a context with an instance of the API client
with marktstammdaten.ApiClient() as api_client:
# Create an instance of the API class
api_instance = daten_api.DatenApi(api_client)
sort = "sort_example" # str | Spalte, nach der auf- oder absteigend sortiert werden soll (optional)
page = 1 # int | Seite, die geladen werden soll (optional)
page_size = 1 # int | Anzahl an Einträgen pro Seite (optional)
filter = "filter_example" # str | Syntax: Feld-name~[eq|neq|sw|ct|nct|ew|null|nn]~'Wert'~[and|or]~... (optional)

# example passing only required values which don't have defaults set
# and optional values
try:
# Erweiterte öffentliche Daten zur Stromerzeugung
api_response = api_instance.einheit_einheit_json_get_erweiterte_oeffentliche_einheit_stromerzeugung_get(sort=sort, page=page, page_size=page_size, filter=filter)
pprint(api_response)
except marktstammdaten.ApiException as e:
print("Exception when calling DatenApi->einheit_einheit_json_get_erweiterte_oeffentliche_einheit_stromerzeugung_get: %s\n" % e)
```

```
Traceback (most recent call last):
File "main_marktstammdaten.py", line 26, in
api_response = api_instance.einheit_einheit_json_get_erweiterte_oeffentliche_einheit_stromerzeugung_get(sort=sort, page=page, page_size=page_size, filter=filter)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/api/daten_api.py", line 168, in einheit_einheit_json_get_erweiterte_oeffentliche_einheit_stromerzeugung_get
return self.einheit_einheit_json_get_erweiterte_oeffentliche_einheit_stromerzeugung_get_endpoint.call_with_http_info(
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/api_client.py", line 997, in call_with_http_info
return self.api_client.call_api(
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/api_client.py", line 452, in call_api
return self.__call_api(
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/api_client.py", line 249, in __call_api
return_data = self.deserialize(response_data, response_type, _check_type)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/api_client.py", line 357, in deserialize
deserialized_data = validate_and_convert_types(
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 1611, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 1485, in attempt_convert_item
raise conversion_exc
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 1472, in attempt_convert_item
return deserialize_model(
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 1377, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 49, in wrapped_init
return fn(_self, *args, **kwargs)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 359, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 49, in wrapped_init
return fn(_self, *args, **kwargs)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model/einheit_einheit_json_get_erweiterte_oeffentliche_einheit_stromerzeugung_get200_response.py", line 198, in _from_openapi_data
setattr(self, var_name, var_value)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 180, in __setattr__
self[attr] = value
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 497, in __setitem__
self.set_attribute(name, value)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 156, in set_attribute
value = validate_and_convert_types(
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 1661, in validate_and_convert_types
input_value[index] = validate_and_convert_types(
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 1611, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 1485, in attempt_convert_item
raise conversion_exc
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 1472, in attempt_convert_item
return deserialize_model(
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 1377, in deserialize_model
return model_class._new_from_openapi_data(**kw_args)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 49, in wrapped_init
return fn(_self, *args, **kwargs)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 359, in _new_from_openapi_data
return cls._from_openapi_data(*args, **kwargs)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 49, in wrapped_init
return fn(_self, *args, **kwargs)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model/entry.py", line 629, in _from_openapi_data
setattr(self, var_name, var_value)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 180, in __setattr__
self[attr] = value
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 497, in __setitem__
self.set_attribute(name, value)
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 156, in set_attribute
value = validate_and_convert_types(
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 1611, in validate_and_convert_types
converted_instance = attempt_convert_item(
File "/home/raphael/.cache/pypoetry/virtualenvs/deutschland-test-pypi-tmto6Anq-py3.8/lib/python3.8/site-packages/deutschland/marktstammdaten/model_utils.py", line 1466, in attempt_convert_item
raise get_type_error(
deutschland.marktstammdaten.exceptions.ApiTypeError: Invalid type for variable 'gemarkung'. Required value type is str and passed type was NoneType at ['received_data']['data'][0]['gemarkung']

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the example in docs/DatenApi.md and compare the response handling with the traceback. Inspect the generated response model and model/entry.py, along with model_utils.py, focusing on the null gemarkung value in received_data['data'][0]. The example is done when this response no longer raises ApiTypeError during deserialization.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.