PDA

View Full Version : HTTPS Get and Post using cookies



miked516
21st February 2017, 21:57
Needing some help with setting up a https get and post to send files to a custom API. I have listed the steps below and was hoping to be able to do this in QT/C++. The steps that I need to do are below. Please let me know if this is possible to do.

Secure HTTP (HTTPS) can be used as a transport for HL7 Messages. The service that will be used to process HL7 messages is a protected resource and requires user authentication. The following steps outline the basic procedure for accessing a protected resource. This process should be used for all HL7 communications.

1. The first step is to connect with the server and obtain a session id. The session id is captured in the HTTP cookie.
o HTTP GET https://websiteurl
o Get the JSESSIONID name-value pair from the “SetCookie” field in the HTTP Response Header. This name-value pair will be added to a variable called <cookie>.
o The variable <cookie> should now look like JSESSIONID=XXXXX

2. The next step is to authenticate your session.
o HTTP GET https://api.websiteurl.com/j_security_check?j_username=a&j_password=b
o The HTTP Request Header should have the field “Cookie” set to the value <cookie>.
o The username and password should be set in the URL Query replacing <a> and <b> values.
o Get the JSESSIONID name-value pair from the “SetCookie” field in the HTTP Response Header. This name-value pair will be added to a variable called <cookie>.
o The variable <cookie> should now look like JSESSIONID=YYYYY

3. Once authenticated, you will be able to access the HL7 server. You may repeat this step as many times as necessary.
o HTTP POST https://api.websiteurl.com/hl7/hl7Server
o The HTTP Request Header should have the field “Cookie” set to the value <cookie>.
o The HTTP Content will be the P03 or A04 message.
o The HTTP Response will contain the ACK message.
o Repeat this step for each HL7 message you need to process.

4. Call logout to expire the session id
o HTTP GET https://api.websiteurl.com/logout
o The HTTP Request Header should have the field “Cookie” set to the value <cookie>.
o This will end your session.

jefftee
22nd February 2017, 04:00
Have you actually tried to implement this at all? If not, take a look at the QNetworkAccessManager, QNetworkRequest, and QNetworkReply classes to get started.