Einzelnen Beitrag anzeigen

Rollo62

Registriert seit: 15. Mär 2007
3.917 Beiträge
 
Delphi 12 Athens
 
#20

AW: REST Problem (Alles geht nur Delphi nicht)

  Alt 11. Jan 2022, 16:34
Und was ist die Moral von der Geschicht' ?

Statt
Delphi-Quellcode:
  RESTClient1.BaseURL := 'https://api.pay1.de/post-gateway/';
  ...

besser die BaseURL und Resource schön separat angeben, so wie es eigentlich gedacht ist.

Delphi-Quellcode:
  RESTClient1.BaseURL := 'https://api.pay1.de';
  RESTRequest1.Resource := 'post-gateway/';       // der Slash ist hier seitens Pay1 notwendig!
  ...
! Und auf Slashes achten ...

Im DocWiki steht dazu Folgendes:

TRESTClient.BaseURL:
https://docwiki.embarcadero.com/Libr...Client.BaseURL
Zitat:
Specifies the base URL for all API calls.

All resources and parameters of your requests will be appended to this URL.
You can add a trailing forward slash to the value of the BaseURL property when resources are empty,
this offers support for web services that expect the trailing slash.
==> OK, das macht Sinn, ... Einer für ALLE ...

TRESTRequest.Resource:
https://docwiki.embarcadero.com/Libr...quest.Resource
Zitat:
This property is added to the base URL to establish a complete URL for the HTTP request.
Important: The Resource value should meet the following limitations:
- Does not include the scheme or domain mame.
- Does not include the leading slash.
==> OK, hier fehlt dann der Hinweis auf "trailing slash"

Deshalb finde ich ein gutes Beispiel besser als tausend Worte
  Mit Zitat antworten Zitat