Using libcurl in photon

Hi @jvanier, thanks for your answer :smile:

I’m working on it since an hour but I’ve never done any http request before, so it’s not that easy for me, I may need some tips or advices.
I’m mostly doing POST requests

EDIT :

I’ve got some trouble with HttpClient.
response.status is -1 and response.body is empty after http.post. I think that this is about authentication, but I don’t know where I missed something.

Here’s my current code :

#include "application.h"
#include "HttpClient/HttpClient.h"

http_header_t headers[] = {
     { "Content-Type", "application/json" },
    //{ "Accept" , "*/*"},
    { "X-Parse-Application-Id", "<MY X PARSE APPLICATION ID"},
    {"X-Parse-REST-API-Key", "<MY X PARSE REST API KEY>"},
    { NULL, NULL } // NOTE: Always terminate headers will NULL
};

HttpClient http;
http_request_t request;
http_response_t response;

void setup() {
    Serial.begin(9600);
    request.hostname = "https://api.parse.com";
    request.port = 80;
    request.path = "/1/classes/Flotty";
}

void loop() {
    Serial.println("Application>\tStart of Loop.");
    
    request.body = "{\"test\":\"TOTO\"}";
    Serial.print("Body: ");
    Serial.println(request.body);
    
    http.post(request, response, headers);
    
    Serial.print("response.status: ");
    Serial.println(response.status);
    Serial.print("response.body: ");
    Serial.println(response.body);
    
    delay(10000);
}