Reading a Global Setting in a script

So I am officially stuck.

I can post the jsondata string to the API with postmaster with website authorisation and without. Works fine.

I can post the jsondata string to the API with Postmaster as Raw body data or as Json. Works fine

I have checked the Registry entries on the server and terminal to ensure that the default TLS version is correct (it was already set as default value (1)

Within SambaPOS I have tried web.PostJson with authorisation and without . Does NOT work

Within SambaPOS I have web.Post Data with authorisation and without. Does NOT work

Last check I have done was to use online API tester at apitester.com . Input the url and string copied and pasted from my script and got this result

The data has also updated on beds24 account. So this works.

Cannot see why SambaPOS does not work. This is pretty fundemental and a simple element that I need to see working before I can build the full POS to PMS API link.

but what response do you get from these?
even if auth or api key etc were incorrect typically a good api should return erro saying whatever the issue is, so if you get nothing its presumably not even getting to their api

Ar you sure about the TLS? Even on the till that updated itself to windows 10 I still had to edit both registy values
 also make sure you restart after changing registry

I am not sure if SambaPos even posts from the script as when it gets to this point the script just drops out to the next action in my rule (Logout). I put a message at the end of the script but this never gets displayed. Message before the web.postjson is always displayed.

The API responds with success and the updated values when I post from Postmaster.

I will have a deeper look into the TLS but I didnt have to edit the values as they were already default (1). I am running this script on a test database using the server and one terminal. There are other terminals on the network but these are connected to the live database. Should I check these?

Looking closer your script looks to have bracket issues. That or your missing an else for the if
 You have }{ in the miggle after SQL and before post prep likes
 Suprised this doesn’t crash or throw and error

Without one or both of these brackets the script does not work.

Script currently executes all lines and displays messages right up until the web.Post line and then crashes. Is there a way to see the script debugger because it tells me nothing. The script Test button is also non operational.

For test you should put in a sample function call with variables quoted and it should pop-up return value or error.

So took on board what you said about the script, cleaned it up, took out superfluous code and brackets, refined the variables and added some dialog to tell me how far we get.

Script works fine, outputs the correct format and information. Every dialog message until the return response line works perfectly. Script exits before the last Dialog Message and DOES NOT post anything.

It is ridiculously easy to post the json string created by this script with Postmaster, online JSon posting or direct input through the API page. SambaPOS will not POST this string. I have tried PostJson, PostData, Upload Data. Nada.

I am beyond frustrated now because of the amount of work I have done with SambaPOS over the last 2 years to tailor to our business (very successfully) and always with the aim of integrating with the right PMS API when I eventually found it. I like the SambaPOS system so much but fundamentally it does not seem to be able to post Data to a quite simple API.

Are you not missing some semmi colons on those last few lines?

Yea spotted those after posting picture. dlg.Mesaage have all had semi colons added but result is the same unfortunately.

web.PostJson implemented for a specific case that requires basic authentication. (remember web pages that displays user name and password dialog when visited).

You can use webclient class to read / post data. If you search for “webclient” or “uploadstring” on the forum you’ll find a lot of usage examples.

2 Likes

Is there some element of my Samba/Server that needs to be activated/enabled to facilitate any Web.Client activity.

Web.Client not working - Have tried a number of scripts for this and it always kiks out the script
Web.Upload not working
Web.PostJson not working
Web.PostData not working

In order to identify if its a problem with the API I have tried posting with all these options to a tame API website called Reqres. none of them even get as far as posting anything to the API.

Something fundemental is not working with Web.Anything

What samba version are you on? My PMS system uses this type of request hevily however live system is not on latest sambapos.
I will update my Dev machine and test the know working in earlier version scripts and let you know. Although I’m sure kendash or q would have picked up on an issue, sure they use this on time text setup but maybe they are using SQL directly

I am using Version 5.2.3 and running Windows Server 2017.

Thanks for your input. My head is now spinning from combinations of scripts and API. Today I did a reset and went back to some basic simple scripts that other people on the forum (yourself included) have got working and modified/tested them on the Reqres API which is designed to give an indication that Posts are being actioned but nothing appears to be being sent.

web.PostJson(url,requestjson,username,password) works for me in 5.2.3.

what do you get on your responce.
Can you paste the actual code here?

web.PostJson(url,requestjson,‘test’,‘test’);
So incorrect user & password returns a null/empty response.

Which is interesting as it used to and does if you go to the url in browser return auth failure message;

{“success”:“false”,“data”:[],“message”:“NewBook REST API Authentication Error (missing parameters)”,“timestamp”:“2018-07-17 03:53:55”,“timezone”:“America/Los_Angeles”,“newbook_version”:“2018.05-21”}

If you are comfortable smaring your full script with user/pass via PM, I can have a quick play if you like?
Im still not sure we have ruled out the tsl v2 issue, You are on a different OS than me but I definatly had to edit the two reg values to make my script work with their api after they changed to v2.

yes no Problem I can PM the script with passwords etc.

I have contacted Beds24 regarding the API and they confirmed the following

  1. The API accepts TLS1.2, all lower protocols are disabled and will not work.

  2. Use the ApiKeys for authentication and IP whitelisting to restrict access only from authorized IP address’s. There is no authorization in the headers required and I have turned off Whitelisting so any IP will work.

  3. There are no special headers required, all you need to do is simulate the POST as per the other systems that are working

The url for the API Post I am attempting is as follows https://www.beds24.com/api/json/modifyProperty

I will save the script and PM to you.

I get;

{“error”:“Unauthorized”,“errorCode”:“1000”}

even if I put usr,psswd in the post


Is there a get type request? To say get a list of rooms or guests as would be a better teting call than a modify request.

Regarding the TLS1.2 I have carried out the following process on the server and all terminals where applicable.

Problem
How to enable TLS 1.2 on Windows Server 2008 R2?
Resolution
QuoVadis recommends enabling and using the TLS 1.2 protocol on your server. TLS 1.2 has improvements over previous versions of the TLS and SSL protocol which will improve your level of security. By default, Windows Server 2008 R2 does not have this feature enabled. This KB article will describe the process to enable this.

Start the registry editor by clicking on Start and Run. Type in "regedit" into the Run field (without quotations).

Highlight Computer at the top of the registry tree.  Backup the registry first by clicking on File and then on Export.  Select a file location to save the registry file.

Note: You will be editing the registry.  This could have detrimental effects on your computer if done incorrectly, so it is strongly advised to make a backup.

Browse to the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols

Right click on the Protocols folder and select New and then Key from the drop-down menu. This will create new folder.  Rename this folder to TLS 1.2.

Right click on the TLS 1.2 key and add two new keys underneath it.

Rename the two new keys as:
    Client
    Server

Right click on the Client key and select New and then DWORD (32-bit) Value from the drop-down list.

Rename the DWORD to DisabledByDefault.

Right-click the name DisabledByDefault and select Modify... from the drop-down menu.

Ensure that the Value data field is set to 0 and the Base is Hexadecimal.  Click on OK.

Create another DWORD for the Client key as you did in Step 7.

Rename this second DWORD to Enabled.

Right-click the name Enabled and select Modify... from the drop-down menu.

Ensure that the Value data field is set to 1 and the Base is Hexadecimal. Click on OK.

Repeat steps 7 to 14 for the Server key (by creating two DWORDs, DisabledByDefault and Enabled, and their values underneath the Server key).

Reboot the server.

Your server should now support TLS 1.2.

Still dont know if it is actually defaulting to 1.2 or indeed if it is sending anything.

It should only be relative to the machine running the script. Guessing its not server for terminals?