Reputation: 6785
example.py
url="http://authserver:5000/account"
params ={'username': username,'email': email, 'password': password}
data = requests.post(url=url, params=params)
this example above works.
I guess my question simply put is what is the equivalent curl command for the above post request?
Kind of an embarrassing question but I have read the docs and checked SO and cannot find an answer, not to mention that I USED to be able to do this and just forgot how.
I am currently trying:
curl -d http://authserver:5000/account "user=test, email=test, password=test"
But have tried many other variations and all return with failed to connect, connection refused.
Upvotes: 0
Views: 711
Reputation: 12501
It's equivalent to:
curl -X POST 'http://authserver:5000/account/?username=test&password=password&[email protected]'
Some hint to find it out:
Write a simple script to dump http request details:
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from flask import Flask, request
app = Flask("HttpDump")
@app.route("/account/", methods=['POST'])
def postAirService():
print 'Headers: '
print request.headers
print 'Payload: '
print request.data
if __name__ == '__main__':
app.run(host='0.0.0.0', port=6789, debug=False)
And then run your script against it, it will get info:
Headers:
Content-Length: 0
User-Agent: python-requests/2.11.1
Connection: keep-alive
Host: localhost:6789
Accept: */*
Content-Type:
Accept-Encoding: gzip, deflate
Payload:
127.0.0.1 - - [22/Mar/2017 05:45:49] "POST /account/?username=test&password=passwd&email=me%40email.com HTTP/1.1" 200 -
Upvotes: 1
Reputation: 16
Try this :
curl -d "user=test&email=test&password=test" http://authserver:5000/account
Upvotes: 0