casablanca

http_client of cpprestsdk/casablanca

大城市里の小女人 提交于 2019-12-12 00:47:20
问题 I have api https://api.gm-system.net/api/authenticate/searchStaffs/searchText which return a list staff. And here is my code to access this api using cpprestsdk with c++. auto fileStream = std::make_shared<ostream>(); // Open stream to output file. pplx::task<void> requestTask = fstream::open_ostream(U("results.html")).then([=](ostream outFile) { *fileStream = outFile; // Create http_client to send the request. http_client client(U("https://api.gm-system.net/api/authenticate/searchStaffs

http server with casablanca crashes if I access the page

夙愿已清 提交于 2019-12-11 20:24:55
问题 I have created a simple application with http_listener from casablanca (or cpprest) library: #include <cpprest/http_listener.h> #include <functional> using namespace web::http::experimental::listener; using namespace web::http; using namespace web; void handle_get(http_request message) { message.reply(status_codes::OK, U("Hello, World!")); }; void handle_post(http_request message) { message.reply(status_codes::NotFound); }; void handle_put(http_request message) { message.reply(status_codes:

Visual Studio 2015: C++ REST API (Casablanca) failing compilation in VS includes/headers

为君一笑 提交于 2019-12-11 06:05:03
问题 I installed Visual Studio 2015 Professional edition today and created a C++ Win32 console application Then I want to use C++ REST SDK (Casablanca), so I downloaded it v14 using NuGet package manager And created a sample program using this link However, when I compiled, I am getting errors in VS includes.. Clicked on first error, it takes to here Can't understand why VS includes are failing compilation. So, I created another project and just put "hello world" and it worked fine Please help

C++ Function Completing Before Other Function Finishes

[亡魂溺海] 提交于 2019-12-11 03:48:35
问题 I am coding a C++ program to interact with the internet using the C++ REST SDK. I have a main function and a webCommunication function. The code is similar to below: void webCommunication(data, url) { //Communicate with the internet using the http_client //Print output } int main() { //Obtain information from user webCommunication(ans1, ans2); system("PAUSE"); } However, it seems that the main function is progressing before the webCommunication function is finished. If I make webCommunication

Reading JSON from a file using C++ REST SDK (Casablanca)

谁说胖子不能爱 提交于 2019-12-11 01:56:32
问题 I have the following code which should read the contents of a text file and parse it as JSON try { string_t importFile = argv[++iArgCounter]; // extract filename ifstream_t f(importFile); // filestream of working file stringstream_t s; // string stream for holding JSON read from file json::value v; // JSON read from input file iArgCounter++; // increment arg counter if (f) { s << f.rdbuf(); // stream results of reading from file stream into string stream f.close(); // close the filestream v

Howto reconnect to a server which does not answer to close()

老子叫甜甜 提交于 2019-12-08 04:31:25
问题 I am using the C++ REST SDK ("Casablanca") to receive feed from websocket servers. Sometimes, I need to close the connection and reconnect. The library does not have a reconnect function, so I close the old connection and simply open a new one. The problem is that the server on the other side does, as it seems, not answer to my close message. This is the code: web::websockets::client::websocket_callback_client* m_clClient; ///... void Connection::reconnect() { std::cout << "Debug 1" << std:

C++ REST SDK (Casablanca) web::json iteration

时光毁灭记忆、已成空白 提交于 2019-12-05 15:23:55
问题 https://msdn.microsoft.com/library/jj950082.aspx has following code. void IterateJSONValue() { // Create a JSON object. json::value obj; obj[L"key1"] = json::value::boolean(false); obj[L"key2"] = json::value::number(44); obj[L"key3"] = json::value::number(43.6); obj[L"key4"] = json::value::string(U("str")); // Loop over each element in the object. for(auto iter = obj.cbegin(); iter != obj.cend(); ++iter) { // Make sure to get the value as const reference otherwise you will end up copying //

C++ REST SDK (Casablanca) web::json iteration

你离开我真会死。 提交于 2019-12-04 01:15:57
https://msdn.microsoft.com/library/jj950082.aspx has following code. void IterateJSONValue() { // Create a JSON object. json::value obj; obj[L"key1"] = json::value::boolean(false); obj[L"key2"] = json::value::number(44); obj[L"key3"] = json::value::number(43.6); obj[L"key4"] = json::value::string(U("str")); // Loop over each element in the object. for(auto iter = obj.cbegin(); iter != obj.cend(); ++iter) { // Make sure to get the value as const reference otherwise you will end up copying // the whole JSON value recursively which can be expensive if it is a nested object. const json::value &str

no suitable user-defined conversion from utility::string_t to std::string

為{幸葍}努か 提交于 2019-11-30 20:36:32
I am using the casablanca C++ Rest library to make HTTP requests. The problem is that this gives a utility::string_t string as output and I can't quite find any way to convert this to a classic std::string. Any ideas? client.request(methods::GET).then([](http_response response) { if(response.status_code() == status_codes::OK) { string_t s = response.extract_string().get(); } }); If you see the documentation for C++ REST SDK from github, you'll find a typedef C++ Rest SDK - utility Namespace Reference typedef std::string string_t; So no need to convert it. Both are same types. Depending on what

Create a json array in C++

最后都变了- 提交于 2019-11-30 12:23:48
So im trying to create a json Object in c++ dynamically. I want to add a timestamp and then an array with the data included. So thats what my json String would look like : { "timestep": "2160.00", "vehicles": [ { "id": "35092_35092_353", "x": "6.988270", "y": "50.872139", "angle": "-20.812787", "type": "passenger_P_14_1", "speed": "0.000000", "pos": "4.600000", "lane": "4.600000", "slope": "4.600000" }, { "id": "35092_35092_353", "x": "6.988270", "y": "50.872139", "angle": "-20.812787", "type": "passenger_P_14_1", "speed": "0.000000", "pos": "4.600000", "lane": "4.600000", "slope": "4.600000"