Sending HTTP requests from Spark Core to API [HttpClient Help]

I am using HTTP client to send request to my API. I am receiving the requests from Spark Core but not the data. I have tried get and post requests both are not working. Here is the complete code

    #include "HttpClient/HttpClient.h"
    * Declaring the variables.
    unsigned int nextTime = 0;    // Next time to contact the server
    HttpClient http;
    // Headers currently need to be set at init, useful for API keys etc.
    http_header_t headers[] = {
          { "Content-Type", "text/html" },
        //  { "Accept" , "application/json" },
        { "Accept" , "*/*"},
        { NULL, NULL } // NOTE: Always terminate headers will NULL
    http_request_t request;
    http_response_t response;
    void setup() {
    void loop() {
        if (nextTime > millis()) {
        Serial.println("Application>\tStart of Loop.");
        // Request path and body can be set at runtime or at setup.
        request.hostname = "";
        request.port = 80;
        request.path = "/api.php";
        // The library also supports sending a body with your request:
        //request.body = "response={\"deviceID\":\""+Spark.deviceID()+"\", \"statusCode\": 1}";
        request.body = "response=1";
        // Get request, response, headers);
        Serial.print("Application>\tResponse status: ");
        Serial.print("Application>\tHTTP Response Body: ");
        nextTime = millis() + 10000;

Any help will be greatly appreciated.


Hi Moazam,

DId you find a solution to this?..I’m facing a similar problem.



Hi Joel,

Yes, I used Rest Client library:

Best of luck!