0

I have a webhook.

data0=[{"senderId":"smsdia","requestId":"******383233353233","report":[{"date":"2017-12-02 17:00:41","number":"12345","status":"1","desc":"DELIVERED"}],"userId":"119385","campaignName":"viaSOCKET"}]

I receive the above data in a POST request to my server.

Content-Type: application/x-www-form-urlencoded

How do I parse it?

I know that if it is a list: data1=['sree','kanth'] I can parse it with request.POST.getlist('data1[]')

But I don't know how to parse when it is a list containing dict.

edit1

Moreover, I get len(data1) is 2. But len(data0) is 0.

edit2 using request.lib: https://requestb.in/13df2891?inspect

3
  • You need to provide more information. This is probably JSON, but it's not at all clear how it is being sent. Please show the code that is posting to your server. Commented Dec 2, 2017 at 12:50
  • I don't have control over the code that is posting to my server. Commented Dec 2, 2017 at 12:52
  • @DanielRoseman Please see the posted data at requestb.in/13df2891?inspect Commented Dec 2, 2017 at 12:52

1 Answer 1

2

This appears to be JSON sent inside a form field. You can use the json library to parse it:

data = json.loads(request.POST['data'])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.