I am not able to send post request properly with 'curl' command
5,809
Your post data contains spaces, replace with "+", It should be correctly encoded.
Related videos on Youtube
Author by
devlin31
Updated on September 18, 2022Comments
-
devlin31 over 1 year
I am very new to django programming.After reading some basic curl command, I am sent the following post request to python server using curl
curl --data "system_uuid=b28964bf-3e9e-47d7-af5e-4e221cc1a697&media_id=1&Status=1&upload_on=2013-12-04 17:15:32" http://127.0.0.1:8000/server/32/1001/2/
to the following url
from django.conf.urls.defaults import patterns handler500 = 'django.views.defaults.server_error' urlpatterns = patterns('server.views', ( r'^server/32/(?P<client_id>\d+)/(?P<msg_version>\d+)/$','check_media_status'),)
my view 'check_media_status' is simple as follows:
def check_media_status(request, client_id, msg_version ): print "Request Accepted" return http.HttpResponse("ok")
but I am constantly getting following error message in my python server
[21/Jul/2014 10:51:43] "POST /server/32/1001/2/ HTTP/1.1" 500 94027
My django version is 1.3.1 & python version is 2.7.3
I am not able to figure out what is going wrong. :(
-
devlin31 almost 10 yearsonly space in post data is between data & time information in 'upload_on'. so, I replaced space with '+' as you told & also with '%20' which i got from same resource where i read about curl as follows curl --data "system_uuid=b28964bf-3e9e-47d7-af5e-4e221cc1a697&media_id=1&Status=1&upload_on=2013-12-04+17:15:32" 127.0.0.1:8000/server/32/1001/2 curl --data "system_uuid=b28964bf-3e9e-47d7-af5e-4e221cc1a697&media_id=1&Status=1&upload_on=2013-12-04%2017:15:32" 127.0.0.1:8000/server/32/1001/2
-
denisvm almost 10 yearsYou should replace spaces with "+", no "%20", POST data is slightly different from query string, which uses %20 for spaces. No problem, we are here to help :)