As part of the learning process about Rest services, i am trying to build a simple HTTP listener using the Microsoft c++ REST sdk "casablanca". My aim initially is to test if it can receive a simple POST request pointed at localhost and save the text in a file.
I am building this project on VS2015. I used the built-in package manager to find and install the sdk, and downloaded the required header files from github and added them as additional include directories. When trying to build , i keep getting "unresolved external symbol" errors with the error code LNK2019
Here is the code so far
#include <cpprest/http_listener.h>
#include <iostream>
#include <stdlib.h>
using namespace web;
using namespace web::http;
using namespace web::http::experimental::listener;
using namespace utility;
using namespace std;
#define TRACE(msg) wcout << msg;
#define TRACE_ACTION(a, k, v) wcout << a << L" (" << k << L", " << v << L")\n";
map<utility::string_t, utility::string_t> dictionary;
void handle_post(http_request request)
{
TRACE(L"\nhandle POST\n");
utility::string_t input;
input = request.to_string();
utility::ofstream_t out("output.txt");
out << input;
out.close();
}
int main(int argc, char** argv)
{
http_listener listener(L"http://localhost:8080");
listener.support(methods::POST, handle_post);
try
{
listener
.open()
.then([&listener]() {TRACE(L"\nstarting to listen\n"); })
.wait();
while (true);
}
catch (exception const & e)
{
wcout << e.what() << endl;
}
}
One of the errors i'm getting:
unresolved external symbol" __declspec(dllimport) public:_thiscall web::uri::uri(wchar_t const*)" (__imp_??0uri@web@@QAE@PB_W@Z) referenced in function_main
Would appreciate if someone could point out to me what i am doing wrong