http post/get messages

Christie Widget Designer Version 6 - Q&A

Moderator: Moderator Group

Forum rules
When asking make sure to include the operating system and the revision of Widget Designer you are using.

http post/get messages

Postby Rutger_Flierman » Tue Mar 15, 2022 9:30 am

I want to create a GUI for a SDVoE ControlServer. Sending commands must be HTTP Post and GET messages, can this be done with WD? The API uses a Websocket for notifications, can a connection to the Websocket work in WD (e.g: ws://localhost:80/api)
All best, Rutger
Rutger_Flierman
 
Posts: 8
Joined: Tue Apr 28, 2020 3:15 pm

Re: http post/get messages

Postby justyn roy » Sun Mar 20, 2022 5:25 pm

At the moment, you can do GET requests with the "HTTPRequestToVar()" for these - you'll get a response to a variable.

POST requests aren't supported natively yet but are possible manually if you want to do the work.
It is not something that's native to Widget - it could be done even in something like Putty.
An example of how to accomplish this in Widget V4 can be found here: http://forum.coolux.de/viewtopic.php?f=4&t=3241&p=9545&hilit=aja#p9545

It is can be done more easily now with concatenation instead of needing to use "VAdd"
Justyn Roy

Online Manual
User avatar
justyn roy
 
Posts: 132
Joined: Tue Sep 27, 2016 1:26 am

Re: http post/get messages

Postby Rutger_Flierman » Tue Mar 29, 2022 2:30 pm

I tried this:
var Command = '{"op" : "leave","subscription_type" : "HDMI","subscription_index" : 0}'
var MSG = ""
MSG = "POST " + "/api/device/000948dd0772 " + "HTTP/1.1 [CR][LF]Connection: keep-alive[CR][LF]"
MSG += "Content-Length: 80" + "[CR][LF] User-Agent: Christie Widget Designer [CR][LF]"
MSG += "Content-Type: application/json [CR][LF][CR][LF]"
MSG += Command
DebugMessage(MSG)

TcpSend(5,MSG)

With Postman I can send this Command and the RX device with MacAdress 000948dd0772 leaves the video stream but from WD no success. Any suggestions?

the HTTPRequestToVar is working :)
Rutger_Flierman
 
Posts: 8
Joined: Tue Apr 28, 2020 3:15 pm

Re: http post/get messages

Postby Daniel Kaminski » Wed Mar 30, 2022 10:43 am

Looks like you are missing a [CR][LF] after the last iine.

MSG += Command + "[CR][LF]"
--
Daniel Kaminski
Pandoras Box Expert
User avatar
Daniel Kaminski
 
Posts: 1071
Joined: Tue Jul 22, 2008 10:55 am
Location: Herten, Germany

Re: http post/get messages

Postby Rutger_Flierman » Wed Mar 30, 2022 1:40 pm

No luck...In the topic from 2018 to control a Datapath the [CR][LF] is also not there in the last line but i added it.

The command line from the debugger looks like this:

POST /api/device/000948dd0772 HTTP/1.1 [CR][LF]Connection: keep-alive[CR][LF]Content-Length: 80[CR][LF] User-Agent: Christie Widget Designer [CR][LF]Content-Type: application/json [CR][LF][CR][LF]{"op" : "leave","subscription_type" : "HDMI","subscription_index" : 0}[CR][LF]

Thanx for the support!
Rutger_Flierman
 
Posts: 8
Joined: Tue Apr 28, 2020 3:15 pm

Re: http post/get messages

Postby Rutger_Flierman » Fri Apr 01, 2022 10:03 am

This is the reply from the control server:
HTTP/1.1 400 Bad Request
Date: Fri, 01 Apr 2022 08:50:01 GMT
Content-Type: application/json
Server: BlueRiver-Control/3.2.0.2
Vary: Origin
Cache-Control: no-store
Connection: close

{
"status" : "ERROR",
"request_id" : null,
"result" : null,
"error" : {
"reason" : "PROTOCOL",
"message" : "Bad request"
}
}

The command line itself is correct because it works when send with Postman or Companion.

thanx, rutger
Rutger_Flierman
 
Posts: 8
Joined: Tue Apr 28, 2020 3:15 pm

Re: http post/get messages

Postby justyn roy » Fri Apr 01, 2022 11:03 pm

The "Content Length" was an issue for me in the past.

I had to change it depending on how many characters I was sending.
Justyn Roy

Online Manual
User avatar
justyn roy
 
Posts: 132
Joined: Tue Sep 27, 2016 1:26 am

Re: http post/get messages

Postby Rutger_Flierman » Mon Apr 04, 2022 12:46 pm

Thanx Justyn, but I copied the length from Postman (same command) and that should be correct then. I tried values from 60 to 80 (in a for loop 8) ) but no success.
Rutger_Flierman
 
Posts: 8
Joined: Tue Apr 28, 2020 3:15 pm

Re: http post/get messages

Postby Martina Protze » Fri Apr 08, 2022 3:04 pm

We solved the issue by adopting the WD message according to the working examples which we checked in more detail.
As said above, currently WD supports only HTTP GET request via commands. To send HTTP POST requests, the workaround is to send messages with a TCP Client. The messages must include special header information and the command itself.

Rutger solved the issue by setting up a temporary TCP Server (Multi!) to which he sent the Postman/Companion messages from which he knew that they were working. So instead of sending them to the BlueRiver Control Server, he sent them to Widget to have a closer look.
Code: Select all
Please create a TCP Server (Multi!) in the Connection Manager on port 8081 (remember the ID, probably 1). If you right-click it there, you can choose "Test" and it shows incoming messages in a list format, character by character (including CR and LF). If you now create a Node > Input > Connections > TCP Input and set it to the ID from the Connection Manager it shows incoming messages in a more readable way.


He then discovered the following and changed the WD message accordingly and it worked. See below a working example:
- both messages show a space after "POST" which is not included in the initial example above
- The User Agent is not necessary
- Host info is included => I think that is very important
- the Content-Length / number of spaces matter

Thanks everybody for your help on this task!
You do not have the required permissions to view the files attached to this post.
Martina Protze
Technical Support, Pandoras Box and Widget Designer
Martina Protze
 
Posts: 199
Joined: Tue Feb 23, 2010 2:47 pm


Return to Widget Designer V6

Who is online

Users browsing this forum: No registered users and 13 guests

cron