From c3944943873f3fae52100ababecff1a6def70d0b Mon Sep 17 00:00:00 2001 From: Magnus-SmariSma <20734986-Magnus-SmariSma@users.noreply.replit.com> Date: Thu, 20 Mar 2025 23:32:12 +0000 Subject: [PATCH] Fix: Correct IUCN API endpoint URL and address connection issues. Updated API URL to v3 and handled connection errors. Replit-Commit-Author: Agent Replit-Commit-Session-Id: e931b5ab-041b-42e7-baf1-50017869cef6 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/e19c6a51-7e4c-4bb8-a6a6-46dc00f0ec99/53d606c0-59ab-45f3-8ac7-7938548fd7ae.jpg --- ...cites-status-401-in-2ms--1742513423785.txt | 26 +++++++++++++++++++ server/routes.ts | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 attached_assets/Pasted--11-28-51-PM-express-serving-on-port-5000-11-29-02-PM-express-GET-api-cites-status-401-in-2ms--1742513423785.txt diff --git a/attached_assets/Pasted--11-28-51-PM-express-serving-on-port-5000-11-29-02-PM-express-GET-api-cites-status-401-in-2ms--1742513423785.txt b/attached_assets/Pasted--11-28-51-PM-express-serving-on-port-5000-11-29-02-PM-express-GET-api-cites-status-401-in-2ms--1742513423785.txt new file mode 100644 index 0000000..b202ac6 --- /dev/null +++ b/attached_assets/Pasted--11-28-51-PM-express-serving-on-port-5000-11-29-02-PM-express-GET-api-cites-status-401-in-2ms--1742513423785.txt @@ -0,0 +1,26 @@ + +11:28:51 PM [express] serving on port 5000 +11:29:02 PM [express] GET /api/cites/status 401 in 2ms :: {"success":false,"connected":false,"message… +11:29:02 PM [express] GET /api/species 200 in 0ms :: {"success":true,"species":[]} +11:29:02 PM [express] GET /api/searches 200 in 1ms :: {"success":true,"searches":[]} +IUCN API check failed: getaddrinfo ENOTFOUND apiv4.iucnredlist.org +11:29:02 PM [express] GET /api/iucn/status 500 in 93ms :: {"success":false,"connected":false,"message… +11:29:03 PM [express] GET /api/cites/status 401 in 1ms :: {"success":false,"connected":false,"message… +11:29:03 PM [express] GET /api/species 304 in 1ms :: {"success":true,"species":[]} +11:29:03 PM [express] GET /api/searches 200 in 1ms :: {"success":true,"searches":[]} +IUCN API check failed: getaddrinfo ENOTFOUND apiv4.iucnredlist.org +11:29:03 PM [express] GET /api/iucn/status 500 in 28ms :: {"success":false,"connected":false,"message… +11:29:32 PM [express] POST /api/token 200 in 8787ms :: {"success":true,"token":{"id":1,"token":"vypRg… +11:29:32 PM [express] GET /api/token 200 in 1ms :: {"token":"vypRgcZfUGD4nCr8jt9Qkwtt","iucnToken":nu… +11:29:43 PM [express] GET /api/species/search 200 in 4033ms :: {"success":true,"data":{"pagination":{… +IUCN API habitats lookup failed: getaddrinfo ENOTFOUND apiv4.iucnredlist.org +11:29:43 PM [express] GET /api/iucn/habitats 500 in 13ms :: {"success":false,"message":"Error from IU… +IUCN API threats lookup failed: getaddrinfo ENOTFOUND apiv4.iucnredlist.org +11:29:43 PM [express] GET /api/iucn/threats 500 in 8ms :: {"success":false,"message":"Error from IUCN… +IUCN API species lookup failed: getaddrinfo ENOTFOUND apiv4.iucnredlist.org +11:29:43 PM [express] GET /api/iucn/species 500 in 6ms :: {"success":false,"message":"Error from IUCN… +11:29:43 PM [express] GET /api/species/8084 200 in 136ms :: {"success":true,"data":{"cites_listings":… +IUCN API conservation measures lookup failed: getaddrinfo ENOTFOUND apiv4.iucnredlist.org +11:29:43 PM [express] GET /api/iucn/measures 500 in 6ms :: {"success":false,"message":"Error from IUC… +11:29:43 PM [express] GET /api/species/8084 200 in 290ms :: {"success":true,"data":[{"id":19400,"iso_… +11:29:44 PM [express] GET /api/species/8084 200 in 309ms :: {"success":true,"data":[{"id":6292,"citat… diff --git a/server/routes.ts b/server/routes.ts index 504996c..cb2392d 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -323,7 +323,7 @@ export async function registerRoutes(app: Express): Promise { try { // Check if the API is working by hitting the version endpoint - const response = await axios.get("https://apiv4.iucnredlist.org/api/v4/information/api_version", { + const response = await axios.get("https://apiv3.iucnredlist.org/api/v3/version", { headers: { "Authorization": `Bearer ${iucnToken}` }