MedAziz11 / Uptime-Kuma-Web-API

Uptime Kuma REST API
211 stars 44 forks source link

Error When Executing "Get All Status Pages" Using API #62

Open Noschvie opened 1 year ago

Noschvie commented 1 year ago

Hello running latest Uptime-Kuma and Uptime-Kuma-Web-API Docker image under RPi4 64 bit.

Command

curl -X 'GET' \
  'http://hadersdorf.myDomain.com:3002/statuspages' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <...>'

Result

Internal Server Error

Uptime-Kuma-Web-API Logs

[2023-11-18 10:10:12 +0100] [7] [ERROR] Exception in ASGI application
Traceback (most recent call last):
  File "/app/venv/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 436, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/app/venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/app/venv/lib/python3.9/site-packages/fastapi/applications.py", line 270, in __call__
    await super().__call__(scope, receive, send)
  File "/app/venv/lib/python3.9/site-packages/starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/app/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/app/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/app/venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 75, in __call__
    raise exc
  File "/app/venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 64, in __call__
    await self.app(scope, receive, sender)
  File "/app/venv/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/app/venv/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 680, in __call__
    await route.handle(scope, receive, send)
  File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 275, in handle
    await self.app(scope, receive, send)
  File "/app/venv/lib/python3.9/site-packages/starlette/routing.py", line 65, in app
    response = await func(request)
  File "/app/venv/lib/python3.9/site-packages/fastapi/routing.py", line 249, in app
    content = await serialize_response(
  File "/app/venv/lib/python3.9/site-packages/fastapi/routing.py", line 138, in serialize_response
    raise ValidationError(errors, field.type_)
pydantic.error_wrappers.ValidationError: 1 validation error for StatusPageList
response -> statuspages -> 1 -> domainNameList -> 0
  invalid or missing URL scheme (type=value_error.url.scheme)

Thanks!

BouncySteak commented 10 months ago

You are making your query based off of Uptime-Kuma itself not the API noted buy the port number you have used.

curl -X 'GET' \
  'http://hadersdorf.myDomain.com:3002/statuspages' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <...>'

Make the correction as so (unless you altered your docker-compose file)

curl -X 'GET' \
  'http://hadersdorf.myDomain.com:8000/statuspages' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <...>'
Noschvie commented 8 months ago

The port number is the correct one

  uptime-api:
    container_name: uptime-api
    image: medaziz11/uptimekuma_restapi
    restart: unless-stopped
    env_file:
      - db.env
    environment:
      - TZ=Europe/Vienna
    depends_on:
      - uptime-kuma
    ports:
      - 3002:8000  # <Host Port>:<Container Port>
    volumes:
      - ./dataRestApi:/db

The /monitors end point works.

curl -X 'GET' \
  'http://hadersdorf.myDomain.com:3002/monitors' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <...>'