I'm building an API with Rails 5 and trying to test post requests locally on the command line with either curl or httpie.
However, I'm using constraints subdomain: 'api'
in my routes and both curl and httpie don't like that. If I open Chrome and go to http://api.localhost:3000/v1/users
, I receive a valid response. However, with httpie I get this error:
http: error: ConnectionError: HTTPConnectionPool(host='api.localhost', port=3000):
Max retries exceeded with url: /v1/users (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection
object at 0x105732550>: Failed to establish a new connection: [Errno 8]
nodename nor servname provided, or not known',)) while doing GET request to
URL: http://api.localhost:3000/v1/users
I'm almost certin this is due to the subdomain but I can't find any documentation anywhere that refers to using subdomains with curl or httpie. How can I do this?