#1 2017-02-01 15:50:29

nicofari64
Member
Registered: 2017-01-31
Posts: 3

Consuming a java rest api with basic authentication

Hi

I am trying to modify a legacy D7 application to consume a java rest api.
Following this (http://stackoverflow.com/questions/2207 … 6#22078306) I stumbled upon mORMot, and downloaded the latest (unstable) version.
In my case, though, this code does not work since my service requires (basic) authentication.
I have tried including the credentials in the url (eg http://username:password@servername:port/api/v1/myservice) but with no success.
Is this kind of url supported ? If so is anywhere an example ?
thanks a lot in advance
bye
NIcola

Offline

#2 2017-02-01 16:24:21

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Consuming a java rest api with basic authentication

You need to add an "Authentication" header to each request, as expected by basic auth scheme.

Offline

#3 2017-02-01 16:28:22

nicofari64
Member
Registered: 2017-01-31
Posts: 3

Re: Consuming a java rest api with basic authentication

ok I will try thanks a lot!

Offline

#4 2017-02-02 16:10:43

nicofari64
Member
Registered: 2017-01-31
Posts: 3

Re: Consuming a java rest api with basic authentication

Now, with the authentication header, it works, thanks.
But now I would need to deserialize the returned json to an object.
Starting with these lines of the above so post:
t := _Obj(['score',1337,'playerName','Sean Plott','cheatMode',False]);
i've tried to figure out how to prepare the variant to be property deserialized but all i have found are examples in which a json is prepared, none of the opposite process.
May you point me to the correct page in the doc ?
many thanks again
nicola

Offline

#5 2017-02-02 17:21:01

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Consuming a java rest api with basic authentication

By calling VariantSaveJSON() as explained ?
https://synopse.info/files/html/Synopse … l#TITLE_37

Offline

Board footer

Powered by FluxBB