Here's my code.
- Code: Select all
Poco::Net::HTTPResponse res;
// On construit la requête.
Poco::URI uri("http://10.1.2.145/form_0_io.htm");
std::string path(uri.getPathAndQuery());
Poco::Net::HTTPClientSession session(uri.getHost(), uri.getPort());
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_POST, path, Poco::Net::HTTPMessage::HTTP_1_1);
// On rempli les paramètres qu'on a besoin.
Poco::Net::HTMLForm form(Poco::Net::HTMLForm::ENCODING_MULTIPART);
form.set("InOu_2", "2");
form.prepareSubmit(req);
form.write(session.sendRequest(req));
session.receiveResponse(res);
std::cout << res.getStatus() << " " << res.getReason() << std::endl;
It seems that the web server is getting the request, since I'm getting a 302 response, but looks like that the form parameters aren't considered, those parameters should trigger an automate and light up a bulb, but is not ...
But through the browser, it works well and gets also to the redirected page.
Html Code here:
- Code: Select all
<html>
<head><title>Test Form Submission</title></head>
<body>
<form action="http://10.1.2.145/form_0_io.htm" method="post">
<input type="hidden" name="InOu_0" value="2"/>
<input type="submit" value="Submit"/>
</form>
</body>
</html>
Any suggestions ?
Thank you
- Pascal





