#1 2018-07-26 17:58:11

jaclas
Member
Registered: 2014-09-12
Posts: 215

Intreface based service and JS client

I have service with method:

function TServiceBase.LogOn(const aEmail, aPassHash, aAPIKey, aResourceIdentifier: RawByteString; aClientSalt: UInt32): RawUTF8;

I call this from Delphi client and method is called properly, in log I see:

[MainEventLog] 2018-07-26 19:51:27.13 call  	ss.Rest.ServicesAccessAdministration.TAccessAdministrationRest(7E94AF60)
 IAccessAdministrationService.LogOn["ZWdveWFAb25ldC5wbA==",
"Y2MyNTBmNTAzMzIyNmVhYjk4Y2ExODliMzBhZmMzYjAwODQ0OGVkMTg0YzFhYWQ0NmQ4NzIwMTQyZTJjMDk2ZA==","QVBJS0VZLUFCQ0RFLUZHSElK",
"WFlaLUFCQy0xMjM=",8493]

but when I call from JS client (based on jquery) then request in log looks:

[MainEventLog] 2018-07-26 19:51:27.13 call  	ss.Rest.ServicesAccessAdministration.TAccessAdministrationRest(7E94AF60)
 IAccessAdministrationService.LogOn{"aEmail":"test@test.pl","aPassHash":"2676afb19748e6fc5ed1320df9f8d4a7c9fb41b6ef997e2cb4998ff10dd1007c",
"aAPIKey":"KEY_FOR_TEST","aResourceIdentifier":"SomeResourceId","aClientSalt":693}

and method LogOn is called with empty parameters (except aClientSalt, this param has value) :-(

I don't JS developer, where I should search problem?

Offline

#2 2018-07-26 18:42:35

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

Re: Intreface based service and JS client

1. Use your browser in debugger mode (F12) to check the outgoing query layout, and compare with what you expect.

2. You are making confusing between RawByteString and RawUTF8, I guess.
Use RawUTF8 for regular text (aEmail, aPassHadh, aApIKey, aResourceIDentifier) and not RawByteString.
As state by the documentation, RawByteString expects some binary content, and converts everything to Base-64 - this is why the Delphi client argument is weird, and the JS client doesn't make the expected request.

Offline

#3 2018-07-27 08:43:13

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: Intreface based service and JS client

You are right, after change param type to RawUTF8 values are corrected. Thx Arnaud!

Offline

Board footer

Powered by FluxBB