[Answered ]-Integrity Error: null value in column "notification_type_id" violates not-null constraint

2πŸ‘

Now whenever I am trying to do a POST call using the url path /api/v1/notification/pk/property_id {where pk and property_id} passed as url parameter.

In POST call, you don’t pass the data in url. It must be passed as request body.

POST /api/v1/notifications/

Request body:

{
  "property_info": "<id>",
  "property_type": "<id>"
}

In the ListCreateAPIView, there is no post method, if you want to override the view for a POST call make use of def create(self, request): method.

Have a look at the implementation[1] of CreateModelMixin.

[1] https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/mixins.py#L14-L23
[2] http://www.django-rest-framework.org/api-guide/generic-views/#listcreateapiview

πŸ‘€Saurabh Kumar

Leave a comment