Not able to find out the error in the code

When I execute this code I get an error saying invalid API key.
But when I checked the api keys of both bolt module and the mailgun api key it was correct.
I am stuck here and unable to sort out this one.

Here is the code please help me if you get something wrong!!!

please post the output after removing the try-except block.