How do you save API response in a json file?

I am trying to save conversation detail API response into a json file, but it gives me an error. All I want is to save 'api_response ' in a json file using python.
api_response = api_instance.post_analytics_conversations_details_query(body)
with open(f'{api_responses_path}_{pageNumber}.json', mode='w') as localfile:
json.dump(api_response, localfile)
TypeError: Object of type AnalyticsConversationQueryResponse is not JSON serializable

If I try to convert to json data,
data = api_response.json()
I get this error - 'AnalyticsConversationQueryResponse' object has no attribute 'json’, Is there a better way ?

Can someone help here, Thanks for reading!

I've added this issue report to API-2635.

@tim.smith
how can I get help on this issue? I mean is there a group called 'API-2635', or it's a deprecated API issue.
Thanks

It's currently on the backlog of open issues. If you know how it can be fixed within the SDK, you can submit a PR to the Python SDK templates. Until the issue is resolved, you'll need to write a method in your code to output the properties the way you want to work around the issue with using json.dump().

Thanks @tim.smith for your reply.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.