0

我关注了这个链接 How to pass parameters in Swagger UI with a post method using viewsets with Django Rest Framework without any model?

网址.py

url(r'^get/vc/?start_date=<start_date>/?end_date=<end_date>/?days=<days>$',views.GetVCBulkData.as_view({'post':'post'}),name='get_vc'),

视图.py

from rest_framework import viewsets

# Create your views here.

class GetVCBulkData(viewsets.ViewSet):
    """
    Creating API to get the VC collection bulk data
    """
    def post(self, request,*args, **kwargs):
        print(request.data)
        start_date = kwargs['data']['start_date']
        end_date = kwargs['data']['end_ate']
        days= kwargs['data']['days']
        print(start_date,'\n', end_date,'\n', days)

错误:

406 错误不可接受:/PV-Reimagine-Bulk-Uploadget/vc/start_date="2021-01-01"/end_date="2021-01-30"/days=7

4

0 回答 0