konosp/adobe-analytics-reports-api-v2.0

ValueError: ('Response code error', '')

Closed this issue · 2 comments

Hi,
thank you for sharing your service.

My colleague and I noticed that a recurrent issue takes place, namely
ValueError: ('Response code error', '')

With some investigations, we pointed out that it seems there's a naive mistake in the code: in the error message, instead of page.text
raise ValueError('Response code error', page.text)
we would have expected page.status_code
raise ValueError('Response code error', page.status_code)
for a clearer error explanation. Don't you agree?

At the same time, notwithstanding these messages, API calls seem to actually work fine from UI.
If this is the case, it might mean that the package does not wait enough for a response from server.
As a first tweak, better performances seem to be achieved if you consider a timeout in the requests.post within the _get_page function , e.g.
page = requests.post( self.analytics_url, headers=analytics_header, data=json.dumps(report_object), timeout=360 )
In this way it seems to work better, but we still encounter issues when making requests for more segments but have no clue for the moment if there's a way for a more stable call.
In case of a status_code 429, maybe a further sleep could be needed?

Tell us if you can update the package and have hints for more stability in the package.

Thank you

Hi @amedeobellodi ,

Thanks for the feedback. Actually I have not really considered those points. Will try to look into them the next few days. Cheers!

Hi @amedeobellodi,

Did a bit of a review today. Thanks for flagging the timeout attribute in requests. It was not something I had noticed. Did some basic changes in the _get_page code.

master...stage

Have not included a loop if the timeout fails. Not sure if something like that would create an issue or its better to throw an error all together if this fails.

What do you think?