This page last changed on Apr 06, 2013 by juha.

Hello,

I'm trying to use the HTTP command protocol to control my Philips JointSpace (JSON POST and GET) enabled TV. However I get the following warning:

ERROR [HTTP-Thread-3]: HttpGetCommand could not execute
org.apache.http.client.HttpResponseException: Not Found
        at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:67)
        at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:54)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:735)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:709)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:700)
        at org.openremote.controller.protocol.http.HttpGetCommand.requestURL(HttpGetCommand.java:176)
        at org.openremote.controller.protocol.http.HttpGetCommand.send(HttpGetCommand.java:136)
        at org.openremote.controller.service.impl.ControlCommandServiceImpl.trigger(ControlCommandServiceImpl.java:95)
        at org.openremote.controller.rest.ControlCommandRESTServlet.handleRequest(ControlCommandRESTServlet.java:77)
        at org.openremote.controller.rest.RESTAPI.doPost(RESTAPI.java:125)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.openremote.controller.rest.support.json.JSONCallbackFilter.doFilter(JSONCallbackFilter.java:63)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:354)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)

My data in the command are:
URL: http://10.0.0.97:1925/1/input/key
Method: POST
Workload: {"key": "ChannelStepDown"}
Polling interval: 120m

I've tried in editing various space positions in the workload field, eg no spaces, spaces between each value, etcetera. Also with polling on 120m and blank. Nothing works, always the same error. OpenRemote Controller v2.0.2.

Thanks in advance.

org.apache.http.client.HttpResponseException: Not Found

This is the usual HTTP 404 Page Not Found error. It would seem that the URL is not correct?

Posted by juha at Apr 06, 2013 18:21

I've tested some commands with a regular programmed PHP page using CURL and those worked.
It seems that the TV standard gives a 404 although the command is received and executed. Is there a workaround for OR to use the HTTP function with POST to a URL without giving an exception for a 404 (otherwise the command is not executed).
Or maybe I have to use the PHP page to relay the commands via OR to the TV... That is also a possibility but not the one I am planning to use.

Thank you.

<?php

$data = array("key" => "ChannelStepUp");                                                                    
$data_string = json_encode($data);                                                                                   
 
$ch = curl_init('http://10.0.0.97:1925/1/input/key');                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'Content-Type: application/json',                                                                                
    'Content-Length: ' . strlen($data_string))                                                                       
);                                                                                                                   
 
$result = curl_exec($ch);

if ($result) {
	echo "command executed! <br />";
	echo $result; 
}
else {
	echo "command not executed. "; 
}

curl_close($ch);
?>

Executing the PHP page results in:

command executed! 
Ok

Posted by arjen at Apr 08, 2013 09:16
Document generated by Confluence on Jun 05, 2016 09:41