python_server/curl_request_example.md

714 B

Example for send request to server with curl

Get HEADERS

curl -I http://localhost:8088

Send GET data

curl 'http://localhost:8088?foo=bar&bin=go'

Send POST data

curl -d "foo=bar&bin=go" http://localhost:8088

Send POST data as JSON

curl -H 'Content-Type: application/json' --data '{"param1":"test1","param2":"test2"}' http://www.test.com

Ignoring bad or self-signed certificates

curl -k https://localhost/my_test_endpoint

Set type of request

# updating the value of param2 to be test 3 on the record id

curl -X 'PUT' -d '{"param1":"test1","param2":"test3"}' \http://test.com/1

Request with BasicHTTPAuth

curl -u <user:password> https://my-test-api.com/endpoint1