I'm using Delphi on RAD Studio 10 Seattle to work with a REST API with DataSnap. It's working on most of the HTTP verbs, except with DELETE. There's the function for it, according to the DataSnap documentation, but when I do a request with the DELETE HTTP Verb, it gives-me the exception "Project RESTApi.exe raised exception class TDSServiceException with message 'Command closed or unassigned".
Follow the code of the DELETE function for the DataSnap API.
function TSM.CancelLista(const ID_LISTA: integer): TJSONObject;
const
_DELETE = 'DELETE FROM listas WHERE id = :id';
begin
with FormPrincipal do
begin
DB_Query.Active := false;
DB_Query.SQL.Text := _DELETE;
DB_Query.ParamByName('id').Value := ID_LISTA;
Try
DB_Query.ExecSQL;
Result.AddPair('Response', 'Lista atualizada com sucesso');
Except on E : Exception do
Result.AddPair('Response', E.Message);
End;
end;
end;
I'm making the requests with a PHP Code Igniter 4.0.4 web app, but already tried it with the Delphi REST Debugger, with the same result.
DB_Query.ExecSQL
? If you put a breakpoint on that line and press F7, where exactly does the exception occur? What datatype is DB_Query? – MartynA