PDA

View Full Version : REST Api



DirectuX
25-10-2018, 09:10
Hi,


TCP/UDP module works on the transport layer (layer 4) of the OSI Model: https://en.wikipedia.org/wiki/OSI_model

Ok.


If you tell me what you are trying to do, maybe I get help on that.

Sure,

I'm studying the practicability of talking with an OrientDB Server instance using the OrientDB RESTful HTTP protocol : http://orientdb.com/docs/last/OrientDB-REST.html

ErosOlmi
25-10-2018, 11:31
I'm studying the practicability of talking with an OrientDB Server instance using the OrientDB RESTful HTTP protocol : http://orientdb.com/docs/last/OrientDB-REST.html

OK perfect.
I've already used thinBasic at work for some WS (Web Services) integration.

thinBasic module to use is "MSXML2"
Start from the few examples in C:\thinBasic\SampleScripts\MSXML2\ directory
In particular "HTTPS_Rest_Api.tbasic" example will show how to connect both sync of async to a bank account to get movements
Documentation and examples of the bank api is at https://www.platfr.io/#/docs/api

Let me know.

Maybe better to start a new thread not to mix tcp and WS
I will split this thread.

Ciao
Eros

DirectuX
25-10-2018, 15:32
Hi,



Let me know.
It seems to me to be the answer, let me have some time to try it.


Maybe better to start a new thread not to mix tcp and WS
I will split this thread.
seen, ok.

John Spikowski
25-10-2018, 19:03
The Windows web server market is minuscule to the real world based on Linux, Apache and Nginx.

ErosOlmi
26-10-2018, 11:14
The Windows web server market is minuscule to the real world based on Linux, Apache and Nginx.
:confused: What's the value of this statement?

DirectuX asked about "consuming" a WS and not "creating" a WS.
Who cares about what OS is the WS located or created if you just need to consume its data?

Please John.

rayleech
26-10-2018, 13:42
According to W3Techs, Linux has a 37% share and Windows a 32% share. I believe the word 'minuscule' was misused.

Given that TB and PB are Windows apps, one bloviated opinion that might be true is: Among servers hosting Windows Web Applications, Linux is nearly irrelevant! :D

DirectuX
26-10-2018, 21:45
Hi,


let me have some time to try it.

ErosOlmi, I'm trying, and now facing an error and a question:


Error code: 262
Error description: Invalid delimiter

when using these functions :
https://www.thinbasic.com/public/products/thinBasic/help/html/serverxmlhttprequest_status.htm
and
https://www.thinbasic.com/public/products/thinBasic/help/html/serverxmlhttprequest_getallresponseheaders.htm


Here, theses functions doesn't even highlight within thinAir. Is it the same for everyone ?

And, can I assume that after initializing an <ServerXMLHTTPRequest> object, I can set request headers before opening a request ? that is to say: use <ServerXMLHTTPRequest>.SetRequestHeader(strHeaderName, strValue) before <ServerXMLHTTPRequest>.Open(bstrMethod, bstrUrl [, bAsync [, bstrUser, bstrPassword]])

DirectuX
27-10-2018, 12:46
Hi,

ErosOlmi, I'm trying, and now facing an error and a question:

Update: one must not put parenthesis at the end of these two functions unlike it is said in the documentation.

Still, the status returned is 0 and the header empty as in the HTTPS rest api example.

DirectuX
27-10-2018, 17:52
Hi,


Still, the status returned is 0 and the header empty as in the HTTPS rest api example.

On the good way, able now to successful login.

Found that console_read() keeps the ending enter key in the string.


remove$(console_read(),ANY $CRLF) removes it.


Still, the status returned is 0 and the header empty

built url was false because of this.

John Spikowski
27-10-2018, 19:00
Sorry Eros!

I missed the point of this thread reading it too quickly.

I use libcurl for my web service needs.

ErosOlmi
28-10-2018, 15:38
Dear DirectuX,

thanks for reporting misleading help on some functions and () at the end.
I will fix parsing and help. And yes, some methods are not colored in thinAir, I will try to fix this.

Regarding your try ... did you check "HTTPS_Rest_Api.tbasic" example?
It uses .getAllResponseHeaders and .getResponseHeader... methods.
Was that example working for you?

Let me know.

DirectuX
28-10-2018, 18:06
Hi,


misleading help on some functions
That is sadly too common to many language, thinBasic manages it rather well. In my opinion php.net 's manual is a good example to follow, regarding documentation; especially "User Contributed Notes" on each page.


And yes, some methods are not colored in thinAir, I will try to fix this.
Note:I've just discovered that there is an autocomplete function in thinAir, it is not enabled by default. Didn't find/looked for the dictionary to add keywords.



Regarding your try ... did you check "HTTPS_Rest_Api.tbasic" example?
It uses .getAllResponseHeaders and .getResponseHeader... methods.
Was that example working for you?
Precisely, I started here. Then I coded from empty script with the help of the online manual. In the example, status is 0 too. But as it is a web-online 2017 example, I didn't expect it to still work. Yet, it is by means of it I found the parenthesis are unwanted.


I'm studying the practicability of talking with an OrientDB Server instance using the OrientDB RESTful HTTP protocol : http://orientdb.com/docs/last/OrientDB-REST.html
Practicability is ok. I proceed further.

Thanks again :good:

DirectuX
28-10-2018, 18:10
And, can I assume that after initializing an <ServerXMLHTTPRequest> object, I can set request headers before opening a request ? that is to say: use <ServerXMLHTTPRequest>.SetRequestHeader(strHeaderName, strValue) before <ServerXMLHTTPRequest>.Open(bstrMethod, bstrUrl [, bAsync [, bstrUser, bstrPassword]])


One more thing,
can you answer this ?

ErosOlmi
28-10-2018, 18:33
ServerXMLHTTPRequest object takes advance of the Microsoft IServerXMLHTTPRequest2 object
Get more info at thinBasic help file https://www.thinbasic.com/public/products/thinBasic/help/html/index.html?msxml2.htm
or Microsoft docs at https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms754586(v=vs.85)

.setRequestHeader should be executed after .Open and before .Send

DirectuX
28-10-2018, 18:51
Get more info at thinBasic help file https://www.thinbasic.com/public/products/thinBasic/help/html/index.html?msxml2.htm
or Microsoft docs at https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms754586(v=vs.85)
I've already seen these pages but this hasn't answer my question regarding thinbasic's module: it may have behave as an object where one can set properties first then call method.


.setRequestHeader should be executed after .Open and before .Send
Ok, that is clear. Thanks ErosOlmi.