Delphi-PRAXiS
Seite 2 von 4     12 34      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   DHL-API mit RESTClient (https://www.delphipraxis.net/216501-dhl-api-mit-restclient.html)

Kas Ob. 8. Jan 2025 12:56

AW: DHL-API mit RESTClient
 
One more thing, i don't have TRESTClient, so may be someone here can help or suggest how to add HTTP header.

Ykcim 8. Jan 2025 13:07

AW: DHL-API mit RESTClient
 
Hi Kas,

thanks for support. At first: Yes I changed the API-Key and I used the provided Key from DHL. Only for the Forum I changed it to xxXXXxxXXXXXxxXX.

I tried it on the DHL-Page, but also there I get the same result:
Code:
{
  "status": 401,
  "title": "Unauthorized",
  "detail": "Unauthorized for given resource."
}
I wrote an ticket to the support. Maybe the problem is not on my site...

Rollo62 8. Jan 2025 13:13

AW: DHL-API mit RESTClient
 
Perhaps the rate limit kicks in, if all failed attemps will be counted too?
Maybe tomorrow is another day :-D

Kas Ob. 8. Jan 2025 13:15

AW: DHL-API mit RESTClient
 
Zitat:

Zitat von Rollo62 (Beitrag 1544943)
Perhaps the rate limit kicks in, if all failed attemps will be counted too?
Maybe tomorrow is another day :-D

That is exactly why i suggested to switch to test server, usually test server response sometime with real value for something like return tracking status, but it depends on the load, as for other functionality like creating shipment it will be unlimited and not for real production.

Redeemer 8. Jan 2025 13:45

AW: DHL-API mit RESTClient
 
Wenn alle Stricke reißen, gäbe es noch Drittanbieter. Wir haben Sendcloud in unserer Delphi-Anwendung integriert, weil die in jedem Tarif eigene Verträge und API können. Kostet natürlich Geld. Bei DPD haben sie öfter Probleme mit Verfügbarkeit, aber andere Versanddienstleister funktionieren zuverlässiger.

Ykcim 8. Jan 2025 14:28

AW: DHL-API mit RESTClient
 
The rate limit can not be the problem, because it never worked. And it should work by 50 times per day, so that I am sure, that the rate is not the reason...

A third part solution is not a alternative for us, because there are to much parcel per day, that the costs are to high.

I hope that it can be fixed, because it is only the first step. The next one should be the creation of shipment labels...

Patrick

Incocnito 8. Jan 2025 16:09

AW: DHL-API mit RESTClient
 
Funfact: Ich hatte aus Spaß versucht die OpenAI-Schnittstelle mit Delphi per TRestClient-Komponenten anzusprechen.
Das geht in der alten Delphi-Version die ich zu Hause habe (10.?) nicht.
Ich musste die THTTPClient-Komponenten benutzen. Da hatte ich mir auch die Karten gelegt.

Liebe Grüße
Incocncito

dummzeuch 8. Jan 2025 16:12

AW: DHL-API mit RESTClient
 
Zitat:

Zitat von Ykcim (Beitrag 1544933)

Zitat:

Funktioniert es denn mit denselben Parametern mit curl?
Das ist eine gute Frage, die ich leider noch nicht beantworten kann.
Ich habe noch nie mit CURL gearbeitet. Habe es mir heruntergeladen, weiß aber nicht, wie ich es anwenden muss, damit ich den Zugang prüfen kann...

Wenn ich den String in CMD eingebe bekomme ich folgende Fehlermeldung:
Code:
U:\>curl -X GET 'https://api-eu.dhl.com/track/shipments?trackingNumber=00341434296527125347' -H 'DHL-API-Key:xxXXXxxXXXXXxxXX'
curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535

Also bei mir funktioniert es soweit. Ich bekomme mangels API-Key natürlich eine Fehlermeldung:

Code:
curl -X GET 'https://api-eu.dhl.com/track/shipments?trackingNumber=00341434296527125347' -H 'DHL-API-Key:xxXXXxxXXXXXxxXX'

{"status":401,"title":"Unauthorized","detail":"Unauthorized for given resource."}
(Das ist unter Linux.)

Uwe Raabe 8. Jan 2025 16:50

AW: DHL-API mit RESTClient
 
Sollten bei Curls unter Windows nicht Double-Quotes verwendet werden?
Code:
curl -X GET "https://api-eu.dhl.com/track/shipments?trackingNumber=00341434296527125347" -H "DHL-API-Key:xxXXXxxXXXXXxxXX"

Ykcim 8. Jan 2025 17:05

AW: DHL-API mit RESTClient
 
Zitat:

Sollten bei Curls unter Windows nicht Double-Quotes verwendet werden?
Mit Hochkomma bekommt man eine Fehlermeldung:
Code:
curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535
Bei Double-Quotes wird es korrekt ausgeführt. Wenn man gar keine Quotes verwendet wird es auch korrekt ausgeführt.
Wobei korrekt ausgeführt bedeutet:
Code:
{"status":401,"title":"Unauthorized","detail":"Unauthorized for given resource."}


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:10 Uhr.
Seite 2 von 4     12 34      

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz