Help with POST Web Request


#1

1) Give a description of the problem
I’m trying to have a virtual switch send a command to Kodi to play a certain TV channel. I have a curl command that works but I’m not able to create a piston that performs the same task.

2) What is the expected behaviour?
When I activate a virtual switch, a webcore piston will run and will send my Kodi player the command to play a TV channel

3) What is happening/not happening?
The piston is running but Kodi is not playing the TV channel
The following curl command works correctly to make Kodi play the TV channel:
curl -i -X POST -H “Content-Type: application/json” -d “{“jsonrpc”: “2.0”, “method”: “Player.Open”, “id”: 1, “params”:{“item”:{“channelid”:3044}}}” http://[email protected]:8080/jsonrpc

**4) Post a Green Snapshot of the piston!
(upload://b2177XecOBdVIH7P2cGFXTeV9UF.png)

5) Attach logs after turning logging level to Full
6/07/2020, 6:17:39 pm +38ms
+0ms ╔Received event [Home].time = 1594016260886 with a delay of -1849ms
+64ms ║RunTime Analysis CS > 15ms > PS > 31ms > PE > 18ms > CE
+67ms ║Runtime (37904 bytes) successfully initialized in 31ms (v0.3.110.20191009) (66ms)
+68ms ║╔Execution stage started
+81ms ║╚Execution stage complete. (13ms)
+83ms ╚Event processed successfully (83ms)
6/07/2020, 6:17:20 pm +765ms
+1ms ╔Received event [Home].test = 1594016240765 with a delay of 0ms
+72ms ║RunTime Analysis CS > 16ms > PS > 35ms > PE > 21ms > CE
+75ms ║Runtime (37900 bytes) successfully initialized in 35ms (v0.3.110.20191009) (72ms)
+76ms ║╔Execution stage started
+87ms ║║Comparison (enum) on is (string) on = true (2ms)
+89ms ║║Condition #2 evaluated true (8ms)
+90ms ║║Condition group #1 evaluated true (state did not change) (9ms)
+92ms ║║Cancelling statement #3’s schedules…
+114ms ║║Sending internal web request to: [email protected]:8080/jsonrpc
+118ms ║║Executed virtual command httpRequest (19ms)
+120ms ║║Requesting a wake up for Mon, Jul 6 2020 @ 6:17:40 PM NZST (in 20.0s)
+138ms ║╚Execution stage complete. (63ms)
+146ms ║Setting up scheduled job for Mon, Jul 6 2020 @ 6:17:40 PM NZST (in 19.976s)
+155ms ╚Event processed successfully (155ms)


#2

I use webcore with Kodi all of the time.

  1. We will need to see a green shot of your piston, specifically your POST command.
  2. Was this piston working and now is not?

#3

Sorry, I hadn’t uploaded the green shot correctly first time round. It’s there now.
This has never worked for me, I’m trying to get it set up for the first time. @Pantheon I’ve read a lot of your posts and the topics and was sure they would lead me to a solution but, so far, it has eluded me.


#4

Make your post call like above and replace my JSON_String with your result string.

See if that works.


#5

Also, you will have to add [ ] at the beginning and the end of your result string…like mine.


#6

If you have a username and password, you will have to make an Authorization header and input that value there. Make it HERE.


#7

To quote you in another topic - You are GOOD. Thanks a lot, it’s working now after I:
added []
created the web request as CUSTOM body type
included the Authorization header


#8

Webcore%20Green%20Check%20II