Logging to troubleshoot API call

This commit is contained in:
mike cullerton 2021-11-03 10:14:11 -04:00
parent e22a9e7173
commit 8b6c8f9518

View File

@ -3,6 +3,7 @@ from json import JSONDecodeError
from typing import List, Optional
import requests
import logging
from crc import app
from crc.api.common import ApiError
@ -30,10 +31,13 @@ class ProtocolBuilderService(object):
if not isinstance(user_id, str):
raise ApiError("protocol_builder_error", "This user id is invalid: " + str(user_id))
url = ProtocolBuilderService.STUDY_URL % user_id
logging.info(f'get_studies: url: {url}')
response = requests.get(url)
if response.ok and response.text:
logging.info(f'get_studies: response.text: {response.text}')
try:
pb_studies = ProtocolBuilderStudySchema(many=True).loads(response.text)
logging.info(f'get_studies: pb_studies: {pb_studies}')
return pb_studies
except JSONDecodeError as err:
raise ApiError("protocol_builder_error",