I have this payload:
"cardType": "CHOICE",
"step": 40,
"title": {"en-GB": "YOUR REPORT"},
"description": {"en-GB": ""},
"options": [
{"optionId": 0, "text": {"en-GB": "Ask me"}},
{"optionId": 1, "text": {"en-GB": "Phone a nurse"}},
{"optionId": 2, "text": {"en-GB": "Download full report"}},
],
"_links": {
"self": {
"method": "GET",
"href": "/assessments/898d915e-229f-48f2-9b98-cfd760ba8965",
},
"report": {
"method": "GET",
"href": "/reports/17340f51604cb35bd2c6b7b9b16f3aec",
},
},
}
I then url encode it like so and redirect to a report view:
url = reverse("my-reports")
reverse_url = encodeurl(data, url)
The urlencode output is returned as this:
"/api/v2/ada/reports?cardType=CHOICE&step=40&title="
"%7B%27en-GB%27%3A+%27YOUR+REPORT%27%7D&description="
"%7B%27en-GB%27%3A+%27%27%7D&options="
"%5B%7B%27optionId%27%3A+0%2C+%27text%27%3A+%7B%27en-GB"
"%27%3A+%27Ask+me%27%7D%7D%2C+%7B%27optionId%27%"
"3A+1%2C+%27text%27%3A+%7B%27en-GB%27%3A+%27Phone+a+nurse"
"%27%7D%7D%2C+%7B%27optionId%27%3A+2%2C+%27text%27%3A+%7B"
"%27en-GB%27%3A+%27Download+full+report%27%7D%7D%5D&_links="
"%7B%27self%27%3A+%7B%27method%27%3A+%27GET%27%2C+%27href%27%"
"3A+%27%2Fassessments%2F898d915e-229f-48f2-9b98-cfd760ba8965"
"%27%7D%2C+%27report%27%3A+%7B%27method%27%3A+%27GET%27%"
"2C+%27href%27%3A+%27%2Freports%2F"
"17340f51604cb35bd2c6b7b9b16f3aec%27%7D%7D"
In my report view I get the payload from the url query string:
class Reports(generics.GenericAPIView):
permission_classes = (permissions.AllowAny,)
def get(self, request, *args, **kwargs):
result = request.GET
data = result.dict()
print(data)
Now the problem is that the output of the transferred data which is printed above has quotes for nested keys.
{
'cardType': 'CHOICE',
'step': '40', 'title': "{'en-GB': 'YOUR REPORT'}",
'description': "{'en-GB': ''}",
'options': "[{'optionId': 0,
'text': {'en-GB': 'Ask me'}},
{'optionId': 1, 'text': {'en-GB': 'Phone a nurse'}}, {'optionId': 2, 'text': {'en-GB': 'Download full report'}}]",
'_links': "{'self': {'method': 'GET', 'href': '/assessments/898d915e-229f-48f2-9b98-cfd760ba8965'}, 'report': {'method': 'GET', 'href': '/reports/17340f51604cb35bd2c6b7b9b16f3aec'}}"
}
Notice the double quote in the "description", "options" keys etc. Is there a way to remove this or pass this across to the view so that when I unwrap it I have the same data I started with.
Thanks