Summary
The error ‘str’ object has no attribute ‘json’ is likely due to an issue with handling the response in the DestinationQuickbooks check function. The code snippet provided shows the use of requests.post, but the response object is commented out, which may be causing the error.
Question
I am getting an error "'str' object has no attribute 'json'
for this check function
def write(
self, config: Mapping[str, Any], configured_catalog: ConfiguredAirbyteCatalog, input_messages: Iterable[AirbyteMessage]
) -> Iterable[AirbyteMessage]:
pass
def check(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> AirbyteConnectionStatus:
try:
client_id = config['client_id']
client_secret = config['client_secret']
refresh_token = config['refresh_token']
access_token = config['access_token']
realm_id = config['realm_id']
authorization_base_url = '<https://appcenter.intuit.com/connect/oauth2>'
token_url = '<https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer>'
scope = ['com.intuit.quickbooks.accounting']
credentials = f"{client_id}:{client_secret}"
base64_credentials = base64.b64encode(credentials.encode()).decode()
headers = {
"Accept": "application/json",
"Authorization": f"Basic {base64_credentials}",
"Content-Type": "application/x-www-form-urlencoded"
}
data = {
"grant_type": "refresh_token",
"refresh_token": refresh_token,
}
#response = <http://requests.post|requests.post>(token_url, headers=headers, data=data)
return AirbyteConnectionStatus(status=Status.SUCCEEDED)
except Exception as e:
return AirbyteConnectionStatus(status=Status.FAILED, message=f"An exception occurred: {repr(e)}")```
<br>
---
This topic has been created from a Slack thread to give it more visibility.
It will be on Read-Only mode here. [Click here](https://airbytehq.slack.com/archives/C027KKE4BCZ/p1705371945669509) if you want to access the original thread.
[Join the conversation on Slack](https://slack.airbyte.com)
<sub>
["error", "str-object", "attribute-json", "destinationquickbooks", "check-function", "requests-post"]
</sub>