[Solved]-When posting to my Django API : errorcom.google.gson.JsonParseException: unable to parse json


You are missing your views.py code here, but I am guessing you are using ListCreateAPIView out of the box. It turns out that django rest framework does not support automatically creating nested objects out of the box, so you’ll need to add your own code to address that functionality. There is good documentation here:




Are you sure it’s not actually a string that is successful rather than a dictionary? I’ve ran into this problem on the Django side, don’t know much about Android.

With python it would be:

import json
your_dict = {...}

# this stringifies the dict

I know you’re doing this on the client, so the code above won’t be your answer, but it’s an idea and hopefully it helps!


You can try this in an alternative way by changing the QuestionSerializer:

class QuestionSerializer(serializers.ModelSerializer):
    answers = serializers.SerializerMethodField()

    class Meta:
        model = Question
        fields = ('id', 'answers', 'created_at', 'text', 'user_id',)

    def get_answers(self,obj):
        ans_set = AnswerSerializer(Answer.objects.filter(question=obj),many=True)
        return ans_set


I think that the data is not well-formed for that service….

{"text":"gf or ed","answers":[{"text":"gf","votes":0,"id":null},{"text":"ed","votes":0,"id":null}],"user_id":"temp user id"}

‘Picture’ doesn’t exist, you don’t send it from android… And Django makes fields ‘required’ by default, so it should be causing your problem …

Have you got any traces from python? Try to debug it.


Leave a comment