https

How to post json data to api using winhttp in c++

泪湿孤枕 提交于 2020-08-25 06:58:31
问题 I need to post json data to api using c++. In the API, I also need to include app_id and app_key as header. Below is the code I am using: std::wstring get_utf16(const std::string &str, int codepage) { if (str.empty()) return std::wstring(); int sz = MultiByteToWideChar(codepage, 0, &str[0], (int)str.size(), 0, 0); std::wstring res(sz, 0); MultiByteToWideChar(codepage, 0, &str[0], (int)str.size(), &res[0], sz); return res; } LPCWSTR additionalHeaders = L"Content-Type: application/json\r\n" + L

How to post json data to api using winhttp in c++

爷,独闯天下 提交于 2020-08-25 06:57:19
问题 I need to post json data to api using c++. In the API, I also need to include app_id and app_key as header. Below is the code I am using: std::wstring get_utf16(const std::string &str, int codepage) { if (str.empty()) return std::wstring(); int sz = MultiByteToWideChar(codepage, 0, &str[0], (int)str.size(), 0, 0); std::wstring res(sz, 0); MultiByteToWideChar(codepage, 0, &str[0], (int)str.size(), &res[0], sz); return res; } LPCWSTR additionalHeaders = L"Content-Type: application/json\r\n" + L

How to post json data to api using winhttp in c++

可紊 提交于 2020-08-25 06:57:09
问题 I need to post json data to api using c++. In the API, I also need to include app_id and app_key as header. Below is the code I am using: std::wstring get_utf16(const std::string &str, int codepage) { if (str.empty()) return std::wstring(); int sz = MultiByteToWideChar(codepage, 0, &str[0], (int)str.size(), 0, 0); std::wstring res(sz, 0); MultiByteToWideChar(codepage, 0, &str[0], (int)str.size(), &res[0], sz); return res; } LPCWSTR additionalHeaders = L"Content-Type: application/json\r\n" + L