REST api on https Protocol

836 views
Skip to first unread message

Milan Mehta

unread,
Oct 27, 2017, 10:40:09 AM10/27/17
to Harbour Users
Dear All,

I need to use REST api on https Protocol. 
I have never used it before. 
Can someone guide or give us small working example ? 
I am sure many of you must be using it. I need to upload and download JSON file using API.

TIA
Milan.

Angel Pais

unread,
Oct 27, 2017, 10:51:40 AM10/27/17
to harbou...@googlegroups.com
Those are 2 very different animals.
JSON uploading / calling can be done independently of the url format of protocoll.

Here you have 3 problems to solve:
1) url decoding on server side, conforming on client side.
2) handling of ssl autentication in your comms.
3) json coding/decoding.



--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-users+unsubscribe@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Milan Mehta

unread,
Oct 27, 2017, 11:21:20 AM10/27/17
to Harbour Users
Dear Angel,

Of the 3 problems you mentioned, we have already handled Json Coding / Decoding part.
I need to take up the first two.

Kindly guide.

TIA
Milan.

Angel Pais

unread,
Oct 27, 2017, 11:51:00 AM10/27/17
to harbou...@googlegroups.com
Part 1 is fairly easy: Just separate your url using / as delimiter


Pretty easy huh ?


Message has been deleted

Teo Fonrouge

unread,
Oct 27, 2017, 2:54:11 PM10/27/17
to Harbour Users

Hi Milan,


Do you need:


1. Build your REST server with Harbour

2. Build your clients with Harbour


In case of 1. :

If you need build your REST server with Harbour then check the Harbor contrib for an

https server at https://github.com/vszakats/harbour-core/tree/master/contrib/hbhttpd,

it has already a simple example on how to build your own eshop, with login access,

list of products and your cart, simple and elegant by Mindaugas Kavaliuskas.


In case of 2. ; you can check some examples of using CURL ( contrib/hbcurl ), or you

can build your own using SSL / TCP Harbour libs, I don't have an example of it.


I've already made small modifications to the original contrib/httpd which allows to

make some additional configurations like set supported methods from client, change

the original init/end tokens to pass values from Harbour to html templates ( AngularJS

uses {{ / }} as init/end token separators for html evaluation and pass additional info

to headers to allow CORS without additional tools o libraries.


It already has a example to serve as HTTP REST provider for the AngularJS quick start

tutorial at:


https://angular.io/guide/quickstart


this Harbour HTTP REST example is at:


https://github.com/tfonrouge/harbour-vszakats/blob/master/contrib/hbhttpd/examples/angularHeroesHTTP.prg



HTH,



best regards,


Teo

dbo...@gmail.com

unread,
Feb 27, 2026, 9:56:11 PMFeb 27
to Harbour Users
Hello all, 
My customer has a vendor (Startel) telling my customer to create a REST query against their host server and retrieve JSON to create a spreadsheet/CSV.
I see information here about creating a 'server' but Startel is the server/host yes?  They can provide a dictionary.
Where do I start to connect, authorize and build a query with Harbour?
Thank you and kind regards,
Dave

cod...@outlook.com

unread,
Feb 28, 2026, 12:59:00 PMFeb 28
to Harbour Users

Hi Dave.

At this moment it is hard to give you some detailed answers. I hope this can help you at least to start working with REST.

To work with REST API I use Harbour ver. 3.2 with Curl, on Windows computers.

Find in this group messages on how to use Curl with POST or GET Http methods, to interact with resources on a server.

I guess you will use GET method to gather JSON data from vendors server.

Vendor must give your customer  Url endpoint which defines how to get JSON data. Also vendor must give information concerning method of authorization, what data must be in request header, etc.

To use Harbour with Curl, you must have Harbour built with Curl and SSL. It can be tricky to do it from Harbour source because there are many variations on how to do it. On this forum there are many messages on that subject.  Or may be you can somewhere find and download binary version of Harbour already built with Curl and SSL.

After your customer receives information from vendor, you can write test functions to send GET request to vendors server. In this forum you can find function examples, or you can ask question. You can also ask ChatGPT (I mean it seriously) in any phase of your work. It can give you useful example functions.

Response from GET request would be JSON data. You will need to process JSON data to make spreadsheet/CSV.

Instead Curl you can use XMLHTTP object (MSXML2.XMLHTTP  or  MSXML2.ServerXMLHTTP.6.0). I have started with Curl and did not used XMLHTTP object. Somebody think that it is even easier to use XMLHTTP object, but I did not used it. Here on forum there are also messages on how to use XMLHTTP object.

Try and ask. I am sure you will succeed.

Best Regards,

Simo.

Osvaldo Ramirez

unread,
Feb 28, 2026, 3:50:33 PMFeb 28
to harbou...@googlegroups.com

Why don't you try UT or HIX from Carles?

Regards

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/f31a64e0-4d3a-4e4d-90b9-f3123d681460n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages