Skip to content

'KeyError' object has no attribute 'status_code' #10

@mjudi

Description

@mjudi

I'm following the documentation but I'm not able to successfully get it to work. The following is my script:

from sacapi.sacapi import SACConnection
from sacapi import sacapi
SAC_CLIENT_ID = ''
SAC_CLIENT_SECRET = ''
SAC_MODEL_ID = ''

1 Make a connection to my own SAC

sac = sacapi.SACConnection("", "")

2 Setup authentication

sac.connect(SAC_CLIENT_ID, SAC_CLIENT_SECRET)

All good so far but when I run the following statement:
md = sac.getModelMetadata(SAC_MODEL_ID)

I get this error:

KeyError Traceback (most recent call last)
File ~\Documents\WinPython\WPy64-31241\notebooks\sacapi\sacapi.py:614, in SACConnection.getModelMetadata(self, providerID)
613 mdMembers = {}
--> 614 for cdMember in currDimResponseJson["value"]:
615 if "DATE" in cdMember:

KeyError: 'value'

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)
Cell In[36], line 1
----> 1 md = sac.getModelMetadata(SAC_MODEL_ID)

File ~\Documents\WinPython\WPy64-31241\notebooks\sacapi\sacapi.py:649, in SACConnection.getModelMetadata(self, providerID)
647 except Exception as e:
648 errorMsg = "Unknown error during token acquisition."
--> 649 if e.status_code:
650 errorMsg = "%s Status code %s from server. %s" % (errorMsg, e.status_code, e.error)
651 raise RESTError(errorMsg)

AttributeError: 'KeyError' object has no attribute 'status_code'

I appreciate if someone can help me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions