From 6c141990ac7a817ed6ca29ffb6e308ff664dbf0c Mon Sep 17 00:00:00 2001 From: Manos Tsagkias Date: Fri, 1 Dec 2017 00:00:47 +0100 Subject: [PATCH] urequests: Set Content-Type to application/json when json param is used. Otherwise, some servers don't recognize the payload as JSON. --- urequests/urequests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/urequests/urequests.py b/urequests/urequests.py index 79f4614b..30a814d8 100644 --- a/urequests/urequests.py +++ b/urequests/urequests.py @@ -71,6 +71,7 @@ def request(method, url, data=None, json=None, headers={}, stream=None): assert data is None import ujson data = ujson.dumps(json) + s.write(b"Content-Type: application/json\r\n") if data: s.write(b"Content-Length: %d\r\n" % len(data)) s.write(b"\r\n")