ushahidi / crowdmap-issues

A centralized repository for filing, tracking and discussing bugs and features in Crowdmap.com and Crowdmap's API.
0 stars 2 forks source link

API doesn't accept true DELETE & PUT #301

Closed brianherbert closed 11 years ago

brianherbert commented 11 years ago

This will work:

curl -X POST https://api.crowdmap.com/v1/posts/10239/ \
    -F "apikey=XYZ" \
    -F "session=XXXXXXX" \
    -F "_METHOD=DELETE"

This will not work:

curl -X DELETE https://api.crowdmap.com/v1/posts/10239/ \
    -F "apikey=XYZ" \
    -F "session=XXXXXXX" 

Either I'm doing this wrong or we should see about making this work, if it's possible.

brianherbert commented 11 years ago

This also doesn't work for "PUT" requests. Updated title.

evansims commented 11 years ago

DELETE and PUT work fine, actually. There's just some minor problems with how you're addressing the API;

  1. You need to include a matching user agent string for that session
  2. Slim only parses HTTP request bodies if the Content-Type is set to x-www-form-urlencoded; pass -d with your CURL request.

Here's a working example: curl -X DELETE https://api.crowdmap.com/v1/posts/123456789 -d "apikey=XYZ&session=ABC" -A "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36"

brianherbert commented 11 years ago

Ah tricky.

Thanks!