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/michael"));
return client.request(methods::GET);
})
// Handle response headers arriving.
.then([=](http_response response)
{
......
}
This one if fine. But with that i just manually input the "michael" searchText
.
How can I make it that it will accept any searchText something like this.
void MyTest(std::string searchText)
{
..... code here
// Create http_client to send the request.
http_client client(U("https://api.gm-system.net/api/authenticate/searchStaffs/" + searchText));
return client.request(methods::GET);
..... code here
}
I already tried this it won't work. Some problem with 'U' macro.
From https://github.com/Microsoft/cpprestsdk/wiki/FAQ the discription of U macro
is says:
The 'U' macro can be used to create a string literal of the platform type. If you are using a library causing conflicts with the 'U' macro, for example Boost.Iostreams it can be turned off by defining the macro '_TURN_OFF_PLATFORM_STRING' before including the C++ REST SDK header files.
If I point my cursor to U
, the error says:
no operator "+" matches these operands operand types are; const wchar_t[57] + const std::string
I hope some can help me. Thanks.