I am not familiar with Poco, but you can just replace std::coutwith std::ostringstreamand then pull a string from it.
So instead:
StreamCopier::copyStream(rs, cout);
use this code
#include <sstream>
std::ostringstream oss;
StreamCopier::copyStream(rs, oss);
std::string response = oss.str();
, , copyToString std::string, +
std::string responseStr;
StreamCopier::copyToString(rs, responseStr);