Is it possible to publish "form data" with the C ++ rest SDK (Casablanca)? I have a specific web service that searches for data to be published in "form data" and not in the body.
This is the C ++ code:
http_client client(L"http://localhost/posttest/jsontest.php"); // Manually build up an HTTP request with header and request URI. http_request request(methods::POST); request.headers().add(L"Content-Type", L"application/json"); request.headers().add(L"Content-Length", L"100"); request.headers().add(L"Host", L"example.com"); request.headers().add(L"X-Requested-With", L"XMLHttpRequest"); request.set_body(obj); return client.request(request).then([id](http_response response) { if (response.status_code() == status_codes::OK) { return response.extract_json(); } else { /* Print bad status code */ wcout << L"Server returned returned status code " << response.status_code() << L'.' << std::endl; } return pplx::task_from_result(json::value()); })
The web service can only use such data (I cannot change it):
$arr = [$_POST['code']]; header('Content-Type: application/json'); echo json_encode($arr);
(This is just a sample of the PHP code that I use for testing)
source share