Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import json
- DB_IP = '127.0.0.1'
- DB_PORT = 5984
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.connect((DB_IP, DB_PORT))
- db_name = 'temperatures'
- doc_id = 'today'
- request = "PUT /" + db_name + "/" + doc_id + " HTTP/1.1n"
- request += "Content-Type: application/jsonnn"
- request += json.dumps({'min_t': 10, 'max_t': 20})
- sock.sendall(request)
- result = sock.recv(4096)
- print result
- HTTP/1.1 400 Bad Request
- Server: CouchDB/1.6.1 (Erlang OTP/19)
- Date: Mon, 27 Mar 2017 20:07:04 GMT
- Content-Type: text/plain; charset=utf-8
- Content-Length: 48
- Cache-Control: must-revalidate
- [debug] [<0.575.0>] 'PUT' /temperatures/today {1,1} from "127.0.0.1"
- Headers: [{'Content-Type',"application/json"}]
- [debug] [<0.575.0>] OAuth Params: []
- [error] [<0.575.0>] attempted upload of invalid JSON (set log_level to debug to log it)
- [debug] [<0.575.0>] Invalid JSON: undefined
- [info] [<0.575.0>] 127.0.0.1 - - PUT /temperatures/today 400
- [debug] [<0.575.0>] httpd 400 error response:
- {"error":"bad_request","reason":"invalid_json"}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement