Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: Inputting a string

$
0
0
I use this code to place GET request from a listenar application to a webpage, from a listenar command line console application
  listener.support(methods::GET, [](http_request req)
    {
        std::cout << "Serving GET" << std::endl;
    req.reply(status_codes::OK, U("Casablanca SDK!"), U("text/html"));
    });
Now I want user to input a string that should be used in req.reply. But this doesn't seem to work.
std::string strName; 
std::cin >> strName; 

req.reply(status_codes::OK, strName, U("text/html"));
It generates this error.
1>Listener.cpp(36): error C3493: 'strName' cannot be implicitly captured because no default capture mode has been specified
 1>Listener.cpp(36): error C2664: 'pplx::task<void> web::http::http_request::reply(web::http::status_code,const utility::string_t &,utility::string_t) const' : cannot convert parameter 2 from 'std::string' to 'const utility::string_t &'
 1> Reason: cannot convert from 'std::string' to 'const utility::string_t'
 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
 ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ========== 
How can I resolve this issue?

Viewing all articles
Browse latest Browse all 4845


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>