Issue #72 invalid

Add documentation on how to POST with curl

Yann Malet
created an issue

This is somehow related to #71. This ticket has been solved by removing the decorator require_extended.

It would be great if you could add somewhere in the doc an explanation on how to use curl to create a blog entry in the blogserver example using JSON and YAML.

thank you

Comments (1)

  1. Yann Malet reporter

    I think I have finally understood the problem for the sake of completeness here it is the curl command and the handler :

    curl v -u testuser:foobar -H 'Content-Type:application/json' -X POST -d '{"content": "second test", "title": "second test"}' http://127.0.0.1:8000/api/posts/?format=json
    
        def create(self, request):
            """
            Creates a new blogpost.
            """
            attrs = self.flatten_dict(request.data)
            if self.exists(**attrs):
                return rc.DUPLICATE_ENTRY
            else:
                post = Blogpost(title=attrs['title'], 
                                content=attrs['content'],
                                author=request.user)
                post.save()
                return post
    
  2. Log in to comment