Answer the question
In order to leave comments, you need to log in
How to accept and parse json from payment aggregator api?
Hello!
I can’t solve the problem in any way, which consists in accepting a POST request from the JSON aggregator API and parsing it.
I do this:
I send the following request via CURL:
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d "{'json':{'data':'here'}}" 127.0.0.1:8000/check/
one = request.body
dump = json.dumps(one) // Без этого шага лоадс падает с ошибкой, об отсутствии двойных кавычек
val = json.loads(dump)
jsd = val[data]
Answer the question
In order to leave comments, you need to log in
Pass valid json as input (with double quotes) and the code will work for you:
val = json.loads(request.body)
print(val['json']['data'])
val = ast.literal_eval(request.body.decode('utf-8'))
print(val['json']['data'])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question