HTTP POST requests

For questions about IRControl, proposals for next releases, ideas for designing page layouts
Post Reply
sgabrio
Posts: 6
Joined: 31 Dec 2020, 01:43

HTTP POST requests

Post by sgabrio » 03 Jan 2021, 22:45

I was successfully using IRControl to control a device with HTTP GET requests such as:

192.168.175.51:8080/jsonrpc?request={"jsonrpc":"2.0","method":"Input.Down","id":1}

After updating that device, it now requires HTTP POST requests. I've gotten the following to work from two other programs, but it fails in IRControl.

192.168.175.51:8080/jsonrpc (in the URL field)
{"jsonrpc":"2.0","method":"Input.Down","id":1} (in the Content field)

The stacktrace shows:

java.io.FileNotFoundException:
http://192.168.175.51:8080/jsonrpc
com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255)
ch.cec.ircontrol.o.i.a(Unknown Source:177)
ch.cec.ircontrol.o.i.a(Unknown Source:3)
ch.cec.ircontrol.setup.activity.p$h.run(Unknown Source:150)
ch.cec.ircontrol.d0.n$c.run(Unknown Source:25)

What am I missing? I feel like maybe it needs "Content-Type:application/json" but I'm not sure how to include it.

info@cec.gmbh
Posts: 197
Joined: 25 Jul 2017, 14:27

Re: HTTP POST requests

Post by info@cec.gmbh » 04 Jan 2021, 21:42

Hi

Normaly the FileNotfoundException appears when the URL does not exist server side. Could you once set the log level to DEBUG and try it again? Width DEBUG Level there are more informations logged into the log system.

kind regards,
Urs

sgabrio
Posts: 6
Joined: 31 Dec 2020, 01:43

Re: HTTP POST requests

Post by sgabrio » 05 Jan 2021, 05:43

Log when sending an HTTP POST request:

DEBUG fireEvent IRControl Application: Refresh-500=refresh
DEBUG fireEvent IRControlApplication: Refresh-30 tooks 7 MilliSecs
DEBUG fireEvent IRControlApplication: Refresh-30=refresh
ERROR Error while executing HTTP Command
DEBUG HTTP POST http://192.168.175.51:8080/jsonrpc {"jsonrpc":"2.0","method": "Input.Down","id":1}
ERROR Device null connected to httpgateway-01 (not accessible)
DEBUG Gateway gcitach-01 is alive
DEBUG iTach Result device,0,0 WIFI device, 1,3 IR endlistdevices
DEBUG Gateway httpgateway-01 is alive
DEBUG Send iTach Command to 192.168.175.50:4998 / getdevices

Log when sending an HTTP GET request:

DEBUG Start Event handling on Composite. Number of threads now 14
DEBUG fireEvent IRControlApplication: Refresh-30=refresh
DEBUG HTTP Result 200
DEBUG HTTP GET http://192.168.175.51:8080/jsonrpc?requ ... wn","id":1}
DEBUG Gateway gcitach-01 is alive
DEBUG iTach Result device,0,0 WIFI device,1,3 IR endlistdevices
DEBUG Gateway httpgateway-01 is alive
DEBUG Send iTach Command to 192.168.175.50:4998 / getdevices

info@cec.gmbh
Posts: 197
Joined: 25 Jul 2017, 14:27

Re: HTTP POST requests

Post by info@cec.gmbh » 09 Jan 2021, 14:56

Hi

FileNotFoundException occurs when the server sends a HTTP Error 404 back to the client. We can't say why this occures, because we do not know what type of device it is. Sometimes it is a carridge return or something other that the server excpects. Maybe you could analyze the traffic (e.g. with the "Package Capture" App) once? Then we can see what is different to calls that are working.

kind regards,
Urs

sgabrio
Posts: 6
Joined: 31 Dec 2020, 01:43

Re: HTTP POST requests

Post by sgabrio » 10 Jan 2021, 05:07

I used Packet Capture and sent the HTTP POST request. The file is found but it's the wrong content type, "text/plain" when it should be "application/json". Is it possible to include the header "content-type:application/json" and if so, how?

From an app that successfully sends the command:
POST /jsonrpc HTTP/1.1
Content-Type: application/json
...

It returns:
HTTP/1.1 200 OK
...

From IR Control:
POST /jsonrpc HTTP/1.1
Content-Type: text/plain
...

It returns:
HTTP/1.1 415 Unsupported Media Type
...

info@cec.gmbh
Posts: 197
Joined: 25 Jul 2017, 14:27

Re: HTTP POST requests

Post by info@cec.gmbh » 10 Jan 2021, 10:14

Hi

Unfortunately it is actually not possible to change the content type. It is fix "text/plain". We will implement the possibility to give the content type as a new feature for HTTP requests in the next release.

kind regards,
Urs

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests