Jump to content

admar

Members
  • Content Count

    13
  • Joined

  • Last visited

Community Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. admar

    Mars TemplateServerDaemon

    How to use How to run MARSTemplateServerDaemon on almalinux
  2. I am working Mars on delphi 12.2 . I have a project using REST . For this job firs used datasnap REST. I did not perfom rmPOST. Because of this now I am using MARS . I perfom rmPOST I am using MarsTemplate . But not working on Almalunix . But working windows and windows console system. I am trying TemplateServerDaemon for linux. compiling no fault. Bu trying on linux . I want to makefile . I am getting marsTemplateServerDaemon.c file not found. to makefile I need marsTemplateServerDaemon.c To do this two file need marsTemplateServerDaemon.o marsTemplateServerDaemon.c How to find TemplateServerDaemon.c where is located file.
  3. admar

    Mars REST Application

    I am working on Mars 1.5 on Delphi 12.2. I am performing this process via the example on MarsTemplate. I was not experiencing any problems when I created a server for Linux on the datasnap rest application before. Now there is MARSTemplateServerDaemon in MarsTemplate that works on Linux. When I create it via Delphi, MARSTemplateServerDaemon.c file is not created. MARSTemplateServerDaemon.o and MARSTemplateServerDaemon.c files should be created at the same time. MARSTemplateServerDaemon.c file is not created. For this reason, I cannot make a makefile.
  4. admar

    DataSnap REST Application

  5. admar

    DataSnap REST Application

  6. admar

    DataSnap REST Application

  7. admar

    DataSnap REST Application

    Thanks...
  8. admar

    DataSnap REST Application

    When I use rmGET, I can insert a database. However, this type of work sends everything open via the URL. This situation is not clear. It is readable via Postman. It is said that it is useful to send it as a JSON object.
  9. admar

    DataSnap REST Application

    Thanks. When I use rmGET, I can insert a database. However, this type of work sends everything open via the URL. This situation is not clear. It is readable via Postman. It is said that it is useful to send it as a JSON object.
  10. admar

    DataSnap REST Application

    POST http://192.168.1.35:8080/datasnap/rest/TServerMethods1/InsertFirma14/{"firstname":"John","lastname":"TOPRAK"} is working on explorerr Not working ........... curl -X POST "http://192.168.1.35:8080/datasnap/rest/TServerMethods1/InsertFirma14" \ -H "Content-Type: application/json" \ -d '{"firstname":"John","lastname":"TOPRAK"}' POST http://192.168.1.35:8080/datasnap/rest/TServerMethods1/InsertFirma14 Content-Type: application/json { "firstname": "John", "lastname": "TOPRAK" }
  11. admar

    DataSnap REST Application

    I am working on Delphi 12.2 datasnap REST Client Application. Whatever I did about it, I was not successful. I don't get any errors while working on rmGET. However, I have not been successful in any of my efforts using rmPOST. No matter how I do it, I get the error [""error": "TServerMethods1.updateInsertFirma14 method not found in the server method list".] The Clint and Server side of my application are as follows. I use Unidac and PostgrSQL during these operations. //CLIENT SIDE procedure TForm1.Button8Click(Sender: TObject); var LJSON: TJSONObject; RESTClient: TRESTClient; RESTRequest: TRESTRequest; RESTResponse: TRESTResponse; begin // Kullanıcı girişlerini kontrol et if Edit1.Text.Trim = '' then begin ShowMessage('Lütfen bir isim girin.'); Exit; end; if Edit2.Text.Trim = '' then begin ShowMessage('Lütfen bir soyisim girin.'); Exit; end; // JSON nesnesini oluştur LJSON := TJSONObject.Create; try LJSON.AddPair('firstname', Edit1.Text.Trim); LJSON.AddPair('lastname', Edit2.Text.Trim); // REST bileşenlerini oluştur RESTClient := TRESTClient.Create('http://192.168.1.35:8080/datasnap/rest'); RESTRequest := TRESTRequest.Create(nil); RESTResponse := TRESTResponse.Create(nil); try RESTRequest.Client := RESTClient; RESTRequest.Response := RESTResponse; RESTRequest.Resource := 'TServerMethods1/InsertFirma14'; RESTRequest.Method := TRESTRequestMethod.rmPOST; // İstek gövdesini ayarla RESTRequest.AddBody(LJSON.ToString, ContentTypeFromString('application/json')); // İsteği gönder RESTRequest.Execute; // Yanıt kontrolü if RESTResponse.StatusCode = 200 then begin ShowMessage('Kayıt başarıyla eklendi.'); Memo2.Lines.Add('Yanıt: ' + RESTResponse.Content); end else begin ShowMessage('Hata: ' + RESTResponse.StatusText); end; except on E: Exception do ShowMessage('Hata oluştu: ' + E.Message); end; finally LJSON.Free; RESTClient.Free; RESTRequest.Free; RESTResponse.Free; end; end; //SERVER SIDE function TServerMethods1.InsertFirma14(const AJSON: string): String; var LJSON: TJSONObject; JSONValue: TJSONValue; UniQuery1: TUniQuery; ResultJSON: TJSONObject; Firstname, Lastname: string; begin ResultJSON := TJSONObject.Create; // Yanıt olarak dönecek JSON nesnesi LJSON := nil; UniQuery1 := nil; try // Gelen JSON verisini çözümle try // JSON string'ini parse et JSONValue := TJSONObject.ParseJSONValue(AJSON); // Burada AJSON'ı doğrudan kullanıyoruz if JSONValue is TJSONObject then LJSON := JSONValue as TJSONObject // JSONValue'yi TJSONObject'e dönüştür else raise Exception.Create('Geçerli bir JSON nesnesi bulunamadı.'); except on E: Exception do raise Exception.Create('JSON parse error: ' + E.Message); end; // JSON verisi boş değilse işleme devam et if not Assigned(LJSON) then raise Exception.Create('Invalid JSON format.'); // Veritabanı Bağlantısını Kontrol Et if not UniConnection1.Connected then raise Exception.Create('Database connection is not open.'); // JSON'dan firstname ve lastname değerlerini al Firstname := LJSON.GetValue('firstname', ''); // Varsayılan olarak boş bir string dönecek Lastname := LJSON.GetValue('lastname', ''); // Varsayılan olarak boş bir string dönecek // Eğer firstname veya lastname boşsa hata oluştur if (Firstname = '') or (Lastname = '') then raise Exception.Create('Firstname or Lastname is missing in the JSON data.'); // Query Oluşturma UniQuery1 := TUniQuery.Create(nil); try //UniConnection1.Commit; UniQuery1.Connection := UniConnection1; UniQuery1.SQL.Text := 'INSERT INTO Firma (firstname, lastname) VALUES (:firstname, :lastname)'; // Parametreleri JSON nesnesinden al UniQuery1.Params.ParamByName('firstname').AsString := Firstname; UniQuery1.Params.ParamByName('lastname').AsString := Lastname; UniQuery1.ExecSQL; // Veriyi veritabanına ekle // Başarılı işlem sonucu ResultJSON.AddPair('status', 'success'); ResultJSON.AddPair('message', 'Firma kaydedildi.'); ResultJSON.AddPair('result', TJSONNumber.Create(1)); // Başarılı sonucu 1 olarak döndür Result := ResultJSON.ToString; // JSON nesnesini string olarak döndür finally FreeAndNil(UniQuery1); // Query nesnesini serbest bırak end; except on E: Exception do begin // Hata durumunda yanıt dön ResultJSON.AddPair('status', 'error'); ResultJSON.AddPair('message', E.Message); // Hata mesajını döndür ResultJSON.AddPair('result', TJSONNumber.Create(0)); // Hata sonucu 0 olarak döndür Result := ResultJSON.ToString; // JSON nesnesini string olarak döndür end; end; // Bellek temizliği FreeAndNil(LJSON); // JSON nesnesini serbest bırak FreeAndNil(ResultJSON); // Yanıt JSON nesnesini serbest bırak end;
×