Ich versuche, eine POST Locke zu tun:Django & TastyPie: request.POST ist leer
curl --dump-header - -H "Content-Type: application/json" -X POST --data '{"item_id": "1"}' http://www.mylocal.com:8000/api/1/bookmarks/
jedoch request.POST immer leer ist.
Unten ist mein modelresource Code:
class BookmarkResource(ModelResource):
class Meta:
queryset = Bookmark.objects.all()
resource_name = 'bookmarks'
fields = ['id', 'tags']
allowed_methods = ['get', 'post', 'delete', 'put']
always_return_data = True
authorization= Authorization()
include_resource_uri = False
def determine_format(self, request):
return "application/json"
def obj_create(self, bundle, **kwargs):
request = bundle.request
try:
payload = simplejson.loads(request.POST.keys()[0])
except:
payload = simplejson.loads(request.POST.keys())
Jeder weiß, was ich bin fehlt?
Vielen Dank im Voraus.
Siehe auch http://stackoverflow.com/questions/1208067/wheres-my-json-data-in-my-incoming-django-request. – Seth
@dannyroa Was unterscheidet "Formulardaten" und "Nichtformdaten"? – rrauenza
... Betrachtet man die Django-Quelle, sieht es so aus, als wäre sie in '_load_post_and_files()' definiert und hängt von 'CONTENT_TYPE' -' multipart/form-data' und 'application/x-www-form-urlencoded' ab – rrauenza