#define CPPHTTPLIB_OPENSSL_SUPPORT #include #include #include #include <./HTTPClient/lib/httplib.h> #include <./HTTPClient/lib/json.hpp> using json = nlohmann::json; using namespace std; int main(void) { httplib::Client cli("https://121.36.33.250:9000"); cli.enable_server_certificate_verification(false); json j = {{"fanId",1053}}; std::string body = j.dump(); httplib::Headers headers = {{"GroupId", "dam"}}; if (auto res = cli.Post("/services/application/api/fan_app/flangeList", headers, body, "application/json")) { cout << res->status << endl; std::wstring_convert> converter; std::wstring wstr = converter.from_bytes(res->body); // 将char数组转换为宽字符数组 std::wcout.imbue( std::locale("chs")); // 将控制台输出的编码格式改为中文编码格式 wcout << wstr << endl; } else { cout << "error code: " << res.error() << std::endl; } return 0; }