我正在测试邮递员的API。
API- http://localhost:5005/abc/xyz 方法-POST 数据-{“ q”:“嗨”} 我正在尝试检查使用哪种编码方法,并相应地进一步处理。我遇到了错误。
def request_parameters(request):
if request.method.decode('utf-8', 'strict') == 'GET':
return {
key.decode('utf-8', 'strict'): value[0].decode('utf-8',
'strict')
for key, value in request.args.items()}
else:
content = request.content.read()
try:
return json.loads(content.decode('utf-8', 'strict'))
except ValueError as e:
logger.error("Failed to decode json during respond request. "
"Error: {}. Request content: "
"'{}'".format(e, content))
raise