Ticket #1206 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

"Content-Type json" header scuppers package POST

Reported by: dread Owned by: wwaites
Priority: critical Milestone:
Component: ckan Keywords:
Cc: rgrp Repository: ckan
Theme: none

Description

Compare these two requests to create a package:

curl http://test.ckan.net/api/rest/package -d '{name:"test"}' -H 'Content-Type: application/json' -H 'X-CKAN-API-KEY: tester'
curl http://test.ckan.net/api/rest/package -d '{name:"test"}' -H 'X-CKAN-API-KEY: tester'

The second one gets the payload through (ckan log):

Retrieving request params: UnicodeMultiDict([('{name:"test"}', u'')])

But the first one causes a ServerError? because the payload (name:"test") doesn't make it to request.POST or request.params:

Retrieving request params: UnicodeMultiDict([])

The only difference is the "ContentType?: application/json" header, which seems a reasonable thing to include. Javascript lib backbone.js (for example) inserts this automatically.

So why does this header cause the payload to not get through to the request object?

Change History

comment:1 Changed 3 years ago by dread

  • Status changed from new to closed
  • Resolution set to fixed

Fixed with cset:149be76faabc on default branch, aiming for ckan 1.4.2.

Thanks for help from Eric Lemoine.

Note: See TracTickets for help on using tickets.