I am try to translate a curl command in python using HTTPSConnection.
The origin curl command is :
curl -X DELETE \
-H "X-LC-Id: "id" \
-H "X-LC-Key: "key" \
-G \
--data-urlencode 'limit=10' \
https://xxx/1.1/logs
The following is a working solution :
connection = httplib.HTTPSConnection("https://xxx")
connection.connect()
connection.request(
"GET",
"/1.1/logs?limit=" + 10,
json.dumps({}),
{
"X-LC-Id" : "id",
"X-LC-Key" : "key",
}
)
results = json.loads(connection.getresponse().read())
return results
This works fine with 10 results returned.
But, the following do not work:
connection = httplib.HTTPSConnection("https://xxx")
connection.connect()
connection.request(
"GET",
"/1.1/logs",
json.dumps({"limit": "10"}),
{
"X-LC-Id" : "id",
"X-LC-Key" : "key",
}
)
results = json.loads(connection.getresponse().read())
return results
This solution returns all the messages from the server instead of 10.
Where should I put those parameters in curl -g filed when used in HTTPSConnection without having to make the request string like :
"/1.1/logs?limit=" + 10 + "&aaa=" + aaa + "&bbb=" + bbb + ...
Any advice is appreciated, thanks :)