Avatar of John Pumphrey, Crestron CTI, DMC-E
John Pumphrey, Crestron CTI, DMC-E
 asked on


Hello Experts!
I am working with a Crestron control system which uses a flavor of C++ in it's base code and trying to POST a command string to a REST based service running on an Apache web server.
I either get a error 501 not implemented or a malformed xml syntax error. The manufacturer of this recording system says I need to separate the url from the body of the xml delivery, they can't tell me how this needs to happen.....

What I am looking for is an example of a working POST to a REST in it's raw form. I have to code everything from scratch as there are no .h header files avalable or any classes to expose.
I have read the mind numbing RFC 2616 and have gotten some insight on structuring the http transaction but no examples for me to compare my delivery. I have very little http experience, my background is 18 yrs in control system programming so I am very weak with http transactions.

I'm just looking for a valid example of a http transaction sending a POST to REST protocol so I can compare what I am doing wrong with my delivery. If the example can be the raw data the http server receives, that would be best for me as I can structure my code to that exact format.

Here's my current senario;
I open port 80 (similar to a telnet session) and send the following as an ascii string, exactly as you see it, note the \n is a CR+LF.

POST /apis/recorders/recorder-0001807b232a-4909-0/recordings

I'll give max points for help on this.
Web Languages and StandardsHTMLXML

Avatar of undefined
Last Comment

8/22/2022 - Mon

What is the REST service's "contract"? Meaning, what are the parameters it is looking for in the call?
John Pumphrey, Crestron CTI, DMC-E

What I have in the example is all of the parameters for the command. I was told I needed to separate the URL from the XML payload and has to be submitted as a http post method. Not sure how to do that and the manufacturer could not offer any assistance.

Take a look at this link to see if it helps:

c++ - Qt Web Service post query - Stack Overflow

It looks like the poster is trying to do something similar - post XML to a REST web service - and the examples given are in C++. You can see how the URL is set up separately in the code and how the XML is sent as an ASCII string in the 2nd example (after the text "Edit:").

You may also need to experiment with the content type as the poster did. Look at the examples as to how the poster coded the call; then look at the answer with the  check mark (meaning it is the one the poster accepted) and the discussion comments directly beneath the answer.

Of course this isn't "raw data the http server receives", but maybe it'll help... I'll keep looking for an example of raw data as I am intrigued...
Your help has saved me hundreds of hours of internet surfing.

This link seems to give examples of POST commands more like what you're trying to do (minus the SOAP wrapper):
TempConvert Web Service (W3Schools example)

The first thing I'd note as far as your own issue goes is that the text after the POST doesn't seem to be a valid web address. It would have to be the URL of the web service to receive your POST.
POST /apis/recorders/recorder-0001807b232a-4909-0/recordings

Open in new window

The next thing is that other things are missing - the HTTP version, the content type and length.

The C++ info I gave you earlier uses C++ methods to put together this information, so you don't have to do it "in the raw", so to speak :) But, if you're doing it raw, it looks like you have to provide this info manually, on separate lines.
John Pumphrey, Crestron CTI, DMC-E

thank you for your support. I tried structuring a post similar to the sample in the link you provided. With the new structure the server just hangs and gives no response.
Not sure what the server is looking for. I tried contacting the manufacturer again and they are not responding to me now. It appears this system was engineered in Japan and sold here so the people I need to talk to are in Japan. Here's my current code, if you see something not correct please let me know.

POST /apis/recorders/recorder-0001807b232a-4909-0/recordings HTTP/1.1\n
Content-Type: application/rest+xml;
<?xml version="1.0" encoding="utf-8"?>

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.