Showing posts with label post. Show all posts
Showing posts with label post. Show all posts

Thursday, September 01, 2011

Django: Quickly testing an authenticated ajax


Make a authenticated post with the django test client and mark simulate an ajax post:
from django.test import Client
c = Client()
c.login(username='jjasinski', password='xxxx')
print c.post('/user/posts/1/',{},HTTP_X_REQUESTED_WITH='XMLHttpRequest')

Friday, December 11, 2009

curl Usage

Send a POST
curl -u joe:1234 -X POST http://localhost:8000/api/1.0/NU1yWdRM5JBjnZpZX/message/ -d "message=test"

-u = username and password
-d = post parameters
-X = request method

Send a POST using data from standard in:
echo "mykey=myvalue" | curl -X POST -d @-  https://mysite.com/

Show verbose output: 
curl -v http://mysite.com/

Ignore SSL key errors:
curl -k http://mysite.com/

Combining them: 
echo "TEST=1
TEST2=2
" curl -X POST -vk -d @- http://mysite.com/