Commit fbce0080 authored by Matthias's avatar Matthias
Browse files

use different method to read request body

parent 255f028b
Pipeline #24582 passed with stages
in 2 minutes and 9 seconds
from flask_restful import Resource, request, reqparse
from flask_restful import Resource, request
from flask_restful import current_app
from helpers.Error import ImportApiError
from datetime import datetime
......@@ -83,31 +83,13 @@ class WriteJobResultToDrupal(Resource):
description: There was a problem
"""
try:
current_app.logger.debug("report data: " + bytes.decode(request.data))
parser = reqparse.RequestParser()
parser.add_argument('earliest')
parser.add_argument('elapsedTime')
parser.add_argument('fatal')
parser.add_argument('ignore')
parser.add_argument('institutionId')
parser.add_argument('latest')
parser.add_argument('messageId')
parser.add_argument('previousMessageId')
parser.add_argument('recordSetId')
parser.add_argument('sessionId')
parser.add_argument('step')
parser.add_argument('success')
parser.add_argument('total')
parser.add_argument('version')
parser.add_argument('warning')
args = parser.parse_args()
fatal = args['fatal']
body = request.get_json(force=True)
current_app.logger.debug("report data: " + json.dumps(body, indent=2))
fatal = body['fatal']
status = 'FAILED'
if fatal == 0:
status = 'SUCCESS'
report = json.dumps(request.json, indent=2)
report += '\n' + args['institutionId'] + ' * ' + args['recordSetId'] + ' * ' +\
args['sessionId'] + ' * ' + args['step']
report = json.dumps(body, indent=2)
return write_results(job_drupal_uuid, job_log_drupal_uuid, status, report)
except ImportApiError as e:
return {'error': e.message}, 500
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment