Dear coders,
I think I found a fix for a problem in the function below.
Where should I report this issue?
The problem is that with the code in pas2js 1.4.18 you will get a 401 error Unauthorized.
This solution was inspired by the code from the function TRESTDataProxy.DoGetData(...)
The file that contains these functions is pas2js\packages\fcl-db\restconnection.pas
If you enable the log (through TSQLDBRestDispatcher.OnLog ) you will see the following message:
(User: ?) Resource: TEST1; Operation: PUT; Status: 401; Text: Unauthorized
Best regards
Simone Giacomelli
function TRESTDataProxy.ProcessUpdateBatch(aBatch: TRecordUpdateBatch): Boolean;
Var
R : TRESTUpdateRequest;
i : Integer;
Method,URl : String;
begin
Result:=False;
For I:=0 to aBatch.List.Count-1 do
begin
R:=aBatch.List[i] as TRESTUpdateRequest;
R.FBatch:=aBatch;
R.FXHR:=TJSXMLHttpRequest.New;
R.FXHR.AddEventListener('load',@R.onLoad);
URL:=FConnection.GetRecordUpdateURL(R);
Case R.Status of
usInserted :
Method:='POST';
usModified:
Method:='PUT';
usDeleted:
Method:='DELETE';
end;
R.FXHR.open(Method,URL);
Connection.SetupRequest(R.FXHR); // <--------- I ADDED THIS LINE. Without it you get a 401
R.FXHR.setRequestHeader('content-type','application/json');
if R.Status in [usInserted,usModified] then
R.FXHR.Send(TJSJSON.Stringify(R.Data))
else
R.FXHR.Send;
end;
Result:=True;
end;