merge-api / merge-sdk-python

The Python SDK for accessing various Merge Unified APIs
Other
0 stars 1 forks source link

Error using `passthrough_create` method #41

Open ahmontero opened 1 year ago

ahmontero commented 1 year ago

Method passthrough_create from PassthroughApi gives me this error:

MergePythonSDK.shared.exceptions.ApiTypeError: Invalid type for variable 'response'. Required value type is dict and passed type was str at ['received_data']['response']

The code I am using is:


# client is configured properly
passthrough_api = PassthroughApi(self.client)

# Variable values:
# method =  'GET'
# path = '/job-applications/xxxx'
# kwargs = {'headers': {'X-Api-Version': '20220708'}, 'request_format': 'JSON'}
data_passthrough_request = DataPassthroughRequest(method, path, **_kwargs)
resp = self.passthrough_api.passthrough_create(data_passthrough_request) # <- Exception raised

I have debugged the code in your library and at the end the request is sent with this info (some data omitted):

URL: https://api.merge.dev/api/ats/v1/passthrough
Method: Post Body :

{'base_url_override': None, 'data': None, 'headers': {'X-Api-Version': '20220708'}, 'method': 'GET', 'multipart_form_data': None, 'normalize_response': False, 'path': '/job-applications/xxxx', 'request_format': 'JSON'}
ankitd33 commented 1 year ago

Hey I think we may already have a solution to fix this issue - do you think you all could try passing in another optional input 'normalize_response' = True to DataPassthroughRequest - that should convert the response to a dict from a str.

Let me know if that still doesnt work!

ahmontero commented 1 year ago

Hi! If I change the code as you say I need to change the response parser. Anyway the error is bit weird, because I am not facing it everytime I call the api. By the way, I do not know if it is related, but lately I am facing a lot of 406 errors when I call the passthrough_create method. I get a response with a 406 status and a Server internal error message. I do not have any hint to know how to fix the error.

ahmontero commented 1 year ago

If this can help you to debug, the response header x-request-id=F3M6LlmkgJAj5BwJpPai is returning 406 error.

ankitd33 commented 1 year ago

Ah I think with the normalize_response option you won't actually need to change your response parser as it should make sure that it always passes back a dictionary which is what it should be passing back (currently the error seems to be it is trying to pass back a string). Some more information is in our docs if you click the 'Show 5 more' button you will see some information on normalize_response. But let me know if that doesn't match up with what you originally thought/that won't work for you!