samedi 11 mai 2019

How can I hit Django api with parameters using Postman?

@must_be_admin_user def patch(self,request,category_id): ''' Updates Data in the Category Parameters Authenticated Admin User , category_id ''' category = get_object_or_404(Category, id=category_id)

   # IF admin is not the Creater of the Category     
    if category.created_by != request.user.id:
        Response(status=status.HTTP_400_BAD_REQUEST, data={"error": "You did not Create this so you cant delete this"})

    category.last_updated = timezone.now()

    updated_category = CategorySerializer(
        category, data=request.data, partial=True)
    if updated_category.is_valid():
        updated_category.save()
        return Response(status=status.HTTP_201_CREATED, data=updated_category.data)

    return Response(status=status.HTTP_400_BAD_REQUEST, data={"error": updated_category.errors})

I want to know how to send category_id using postman . I am facing issues hitting this api using postman

Aucun commentaire:

Enregistrer un commentaire