Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:15 29 May 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Question about HTTPS/TLS

Author Message
Doktorn

Newbie

Joined: 09/07/2019
Location: Sweden
Posts: 27
Posted: 05:23pm 26 May 2026
Copy link to clipboard 
Print this post

Hi all

Has anyone used WebMite 2350 with the new HTTPS/TLS?
I have tried to make an API request but can't get it to work.
I only get  400 Bad Request.
How should I format a REQUEST for the following web site?

https://www.elprisetjustnu.se/api/v1/prices/2026/05-26_SE4.json

The code below worked with the previous version 5.07.07RC3 of WebMite with TLS.

Dim buff%(8192/8)
Dim b$=”GET /api/v1/prices/2023/04-15_SE4.json” +Chr$(10)+Chr$(13)

WEB open tls client Wwww.elprisetjustnu.se”,443
WEB tls CLIENT REQUEST b$,buff%(),10000
Pause 1000
WEB close tls client

/Lasse
N/A
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11381
Posted: 05:49pm 26 May 2026
Copy link to clipboard 
Print this post

The old request was malformed but the previous TLS stack was lenient enough to let it through. The new mbedTLS path needs a proper HTTP/1.1 request — specifically a CRLF (not LF+CR), an HTTP/1.1 version token, a Host: header, and a blank line terminator.
Note the b$ lines will need connecting together.
Dim buff%(8192/8)
Dim CRLF$ = Chr$(13) + Chr$(10)
Dim b$ = "GET /api/v1/prices/2026/05-26_SE4.json HTTP/1.1" + CRLF$ + "Host:  _
www.elprisetjustnu.se" + CRLF$ + "User-Agent: WebMite" + CRLF$ + "Accept:  _
application/json" + CRLF$ + "Connection: close" + CRLF$        + CRLF$

WEB OPEN TLS CLIENT "www.elprisetjustnu.se", 443
WEB TCP CLIENT REQUEST b$, buff%(), 10000
LongString print buff%()
Pause 1000
WEB CLOSE TCP CLIENT

Key points vs. your original:

CRLF order: HTTP requires \r\n (Chr$(13)+Chr$(10)), your code had them reversed.
HTTP version: must include HTTP/1.1 after the path.
Host header: mandatory in HTTP/1.1 and required by virtual-hosted servers like this one; without it you'll usually get a 400.
Blank line: a request ends with an extra CRLF on its own.
Connection: close: makes the server close after responding so your buffer/timeout behavior is predictable.
Fixed the Wwww typo and the smart quotes (” → ") — those would also fail to compile as-is.
 
Doktorn

Newbie

Joined: 09/07/2019
Location: Sweden
Posts: 27
Posted: 07:49pm 26 May 2026
Copy link to clipboard 
Print this post

Peter

I didn't copy the code, I typed it in, so the mistake was that I
typed shift-w instead of shift-2. These keys are quite
close to each other. I don’t know about the inverted \n\r, it worked
at least with the old code. Now it works as expected, only get the
Invalid JSON data. As you pointed out in the discussion last November
”The json listed doesn’t confirm to the norm” so I have to insert the needed
part[1].name. Strange however because both MicroPython and
Annex RDS decodes the same JSON without complains.
Many thanks for the help.

/Lasse
N/A
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026