arduino-restclient
arduino-restclient copied to clipboard
Fixed Requests!
trafficstars
How is it possible to make dynamic requests using this library?
The following code snippets will NOT work since you made the URL of the GET Request and the Body of the POST Requests Constant.
// GET Request. int statusCode = client.get("/api/myservice/id=" + id, &response);
// POST Request. char postdata = /* Some data from function parameter, for example. */; int statusCode = client.post(""/api/myservice/id", postdata , &response);
@CyborgHead Build your request in a String object and then use .c_str() to convert to a const char*, like so:
String data = "/api/myservice/id=" + id;
int statusCode = client.post("/api/myservice/id", data.c_str() , &response);