JSON Rest

I looked at a few examples on the forum and can’t seem to figure it out.

Tried on Windows/Mac 2016r3

If you go to: https://jsonplaceholder.typicode.com/posts/1
should return

{
userId: 1,
id: 1,
title: "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
body: "quia et suscipit suscipit recusandae consequuntur expedita et cum reprehenderit molestiae ut ut quas totam nostrum rerum est autem sunt rem eveniet architecto"
}

I get nothing. I have tried url without “https://” and still no data

Dim socket1 As New HTTPSecureSocket socket1.ConnectionType = SSLSocket.TLSv12 socket1.SetRequestContent("","application/json; charset=utf-8") Dim jsonData As String = socket1.Get("https://jsonplaceholder.typicode.com/posts/1", 30) MsgBox(jsonData)

Thank you.

Instead of using MsgBox, use a breakpoint. There may be more information in socket1 like an error code, or headers that have some information for you.

Thank you for the reply,

I did some digging and found LastErrorCode 102 which is:
This code means that you lost your connection.
You will get this error if the remote side disconnects (whether its forcibly- by pulling their ethernet cable out of the computer), or gracefully (by calling SocketCore’s Close method). This may or not be a true error situation. If the remote side closed the connection, then it is not truly an error; it’s just a status indication. But if they pulled the ethernet cable out of the computer, then it really is an error; but the results are the same. The connection was lost. You will also get this error if you call the Disconnect method of TCPSocket.

It just doesn’t make sense to me.

This line is wrong. I suspect that what you want is a header that says

Accept-Encoding: application/json; charset=utf-8

To do that you need to use the SetRequestHeader method.

Dim socket1 As New HTTPSecureSocket socket1.ConnectionType = SSLSocket.TLSv12 socket1.SetRequestHeader("Accept-Encoding:", "application/json; charset=utf-8") Dim jsonData As String = socket1.Get("https://jsonplaceholder.typicode.com/posts/1", 30)

Same LastErrorCode 102

Take out the colon. That’s added automatically.

It’s also worth noting that the old socket is only http/1.0 and that the server may be rejecting it for that reason.

Thank you,

I was able to get the code working with the Non-ssl socket. I think there might be something related to the server itself because I did a call on another SSL JSON server (dev) and it was fine.

It could be that it doesn’t support tls v1.2. You might want to try the other two tls settings.

It turned out to be the version of openssl on the server that was causing the issue. Once it was updated, the connection didn’t have a problem. Sorry for not following up.