Reputation: 843
I am using the python library requests
to attempt to send a post request to my local server. I have successfully installed and imported requests--I just can't seem to post or get data from my local server.
Both the server and my python program are on the same machine, the server is currently Django's development server.
What I am trying:
domain = 'localhost:8000'
user = 'username'
password = 'password'
data = 'some data to be sent'
r = requests.post(domain, data auth=(user,password))
Exception raised:
raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for 'localhost:8000'
I have done all the basic things like ensuring that the server was up and running. I have also tried to substitue localhost with 127.0.0.1:8000.
Upvotes: 2
Views: 3880
Reputation: 599600
You need to use a proper URL including protocol:
domain = 'http://localhost:8000'
Upvotes: 6