0
我想在一个请求中发送多个json对象,但我无法从中提取值。Django无法处理多个请求
def config(request):
print "type",type(request)
print "request in config",request.body
if request.method == 'POST':
print "In Handler"
print "Request Body is ",request.body
data = simplejson.loads(request.body)
for i in data:
print "REQUEST is ____",i
z = json.dumps(i)
rew = retResp(z)
proID = request.data["proId"]
对于请求1可以找到proID但请求2我无法获得proID。
req1 = curl -X POST http://192.168.2.242:8080/server/config/ -d '{"confMsgReqId": 2,"proId":"123"}' -H "Content-Type: application/json"
req2 = curl -X POST http://192.168.2.242:8080/server/config/ -d '[{"confMsgReqId": 2,"proId":"123"},{"confMsgReqId": 2,"proId":"345"}]' -H "Content-Type: application/json"
更早些时候我一次只使用request.data [“element”]处理一个请求,而对于这个项目,我使用这个(request.data [“element”])方法。所以,我需要改变我的项目中的任何地方。我的意思是我不能提出两个新的请求(词典) –
现在能够完成更改,谢谢@alasdair,对不起,我错误地解释了你的观点。 –