I’ve had some wireless tag sensors for several years and have been using them to provide email notifications based on movement. I’ve recently put one in my fridge and would like to configure the URL calling feature to post the sensor temperature to an item in OH. However, I can’t seem to get it to work.
Executing the following command on the command line updates the item:
I’ve turned on debug logging for org.eclipse.smarthome.io.rest.core and I can see other items being updated via the REST API but nothing from the wireless tag manager. If I run that curl command I mentioned in the first post then I see this in the log:
26-Jul-2019 21:47:11.819 [DEBUG] [.smarthome.io.rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/wirelessTagFridge' with value '666'.
Very strange. It’s not like the tag manager can’t access the OH server, they’re on the same LAN.
{"error":{"message":"HTTP 404 Not Found","http-code":404,"exception":{"class":"javax.ws.rs.WebApplicationException","message":"HTTP 404 Not Found","localized-message":"HTTP 404 Not Found"}}}
and the following appears in the debug log for org.eclipse.smarthome.io.rest.core:
26-Jul-2019 22:10:40.444 [INFO ] [.smarthome.io.rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/asdasdf' for the unknown item 'asdasdf'.
I’ve found a calling URL log within the wireless tag manager which lists several entries like this:
07/26-21:02:07Z:Did URL Call from Tag Manager: PRIVMSG xyz :@192.168.0.20:8080/rest/items/wirelessTagFridge^POST|--header "Content-Type: text/plain" --header "Accept: application/json" -d "9.62836456298828"
It just looks like the URL call isn’t reaching the OH server, very strange.
"The URL calling supports only application/json or application/x-www-form-urlencoded content type (determined by if the content starts with { )
Please configure your URL end point so it accepts either format. "
I’ve tried simply setting the content to “{2}” before and it still didn’t work. I’m not sure what to try next.
After a bit more back and forth with support I got this reply:
"The equivalent thing the tag manager is doing is
curl -X POST --header “Content-Type: application/x-www-form-urlencoded” -d “-1.40776121616364” “http://192.168.0.20:8080/rest/items/wirelessTagFridge”
Try that and see if your server accept it. "
Running that curl command on the command line gives:
{"error":{"message":"HTTP 415 Unsupported Media Type","http-code":415,"exception":{"class":"javax.ws.rs.NotSupportedException","message":"HTTP 415 Unsupported Media Type","localized-message":"HTTP 415 Unsupported Media Type"}}}
I wish they’d have just told me this in the first place!
After some more googling it looks like I need to implement a reverse proxy to rewrite “application/x-www-form-urlencoded” to “Content-Type: text/plain”.