Warning:: Rank newb here....
I'm trying to get my first RESTful (client) program working, talking to a Philips Hue (light) controller that's on my network -- it's a REST server.
Here's my very simple program (that doesn't work)...
I can get the same data fine from controller user the integrated web interface. The data is suppsed to look like '{ "name": "bla bla bla", "mac": <etc> }
I'm using VS2014 (Pro) with Casablanca 1.3.1
Any ideas appreciated.
I'm trying to get my first RESTful (client) program working, talking to a Philips Hue (light) controller that's on my network -- it's a REST server.
Here's my very simple program (that doesn't work)...
// HueCmdLine.cpp : Defines the entry point for the console application.
//
#include <cpprest/http_client.h>
#include <cpprest/json.h>
#include <exception>
using namespace std;
using namespace web;
using namespace web::http;
using namespace web::http::client;
#ifdef _MS_WINDOWS
int wmain(int argc, wchar_t *args[])
#else
int main(int argc, char *args[])
#endif
{
http_client client(U("http://192.168.1.113/api/newdeveloper/config"));
std::cout << "Starting...";
client.request(methods::GET)
.then([](http_response response)
{
if (response.status_code() == status_codes::OK)
{
try {
auto bridgeConfig = response.extract_string().get();
//auto bridgeConfig = response.extract_json().get();
wcout << bridgeConfig << "Ending" << std::endl;
}
catch (exception & err) {
std::cout << "ERROR:" << err.what() << std::endl;
}
}
})
.wait();
return 0;
}
My problem is, when I try to interpret the http_response, the extract_json throws an exception (Unexpected token near line 1, column 1). When I try to interpet the data with extract_string (I know I shouldn't as I see from response.header that the Content-Type is 'application/json'), I get an empty sting (but the program terminates without an exception).I can get the same data fine from controller user the integrated web interface. The data is suppsed to look like '{ "name": "bla bla bla", "mac": <etc> }
I'm using VS2014 (Pro) with Casablanca 1.3.1
Any ideas appreciated.