mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Fixed bug where the content header was not being passed onto the post
request. Changed data => json. Added extra logging to display the error with more detail
This commit is contained in:
@@ -205,8 +205,9 @@ def preview_letter_template_by_notification_id(service_id, notification_id, file
|
||||
|
||||
pdf_file = get_letter_pdf(notification)
|
||||
|
||||
except botocore.exceptions.ClientError:
|
||||
current_app.logger.info
|
||||
except botocore.exceptions.ClientError as e:
|
||||
current_app.logger.exception(
|
||||
'Error getting letter file from S3 notification id {}'.format(notification_id), e)
|
||||
raise InvalidRequest('Error getting letter file from S3 notification id {}'.format(notification_id),
|
||||
status_code=500)
|
||||
|
||||
@@ -253,13 +254,23 @@ def preview_letter_template_by_notification_id(service_id, notification_id, file
|
||||
def _get_png_preview(url, data, notification_id):
|
||||
resp = requests_post(
|
||||
url,
|
||||
data=data,
|
||||
json=data,
|
||||
headers={'Authorization': 'Token {}'.format(current_app.config['TEMPLATE_PREVIEW_API_KEY'])}
|
||||
)
|
||||
|
||||
if resp.status_code != 200:
|
||||
current_app.logger.exception(
|
||||
'Error generating preview letter for {} \nStatus code: {}\n{}'.format(
|
||||
notification_id,
|
||||
resp.status_code,
|
||||
resp.content
|
||||
))
|
||||
raise InvalidRequest(
|
||||
'Error generating preview for {}'.format(notification_id), status_code=500
|
||||
'Error generating preview letter for {} \nStatus code: {}\n{}'.format(
|
||||
notification_id,
|
||||
resp.status_code,
|
||||
resp.content
|
||||
), status_code=500
|
||||
)
|
||||
|
||||
return base64.b64encode(resp.content).decode('utf-8')
|
||||
|
||||
Reference in New Issue
Block a user