Duration: ~10 minutes
Role: Gateway Operator
Prerequisite: appsettings.json access
DSN (Data Source Name) defines preconfigured database connections.
# List all configured DSN (API) curl -s http://localhost:5000/api/v1/dsn | jq # Or check directly in config cat appsettings.json | jq '.Gateway.Databases'
Edit appsettings.json:
{ "Gateway": { "Databases": { "demo": { "Provider": "sqlite", "ConnectionString": "Data Source=data/demo.db" }, "production": { "Provider": "sqlserver", "ConnectionString": "Server=sql01;Database=ProdDB;User Id=app;Password=***;TrustServerCertificate=True" }, "reporting": { "Provider": "postgresql", "ConnectionString": "Host=pg01;Database=reports;Username=reader;Password=***" } } } }
Supported Providers:
| Provider | ConnectionString Example |
| ———- | ————————– |
sqlserver | Server=host;Database=db;User Id=user;Password=pwd |
sqlite | Data Source=path/file.db |
postgresql | Host=host;Database=db;Username=user;Password=pwd |
mysql | Server=host;Database=db;User=user;Password=pwd |
# Windows Stop-Process -Name "WvdS.WebAPI.Data.Gateway.Api" -Force Start-Process -FilePath ".\WvdS.WebAPI.Data.Gateway.Api.exe" # Linux (systemd) sudo systemctl restart data-gateway
# List tables of new DSN curl -s http://localhost:5000/api/v1/dsn/production/tables | jq # Fetch first data curl -s "http://localhost:5000/api/v1/dsn/production/tables/Customers?\$top=5" | jq
appsettings.jsoncurl -s http://localhost:5000/api/v1/dsn/old_dsn/tables # Expected response: 404 Not Found
| # | Check | Done |
| — | ——- | —— |
| 1 | Provider correct (sqlserver/sqlite/…) | [ ] |
| 2 | Connection string valid | [ ] |
| 3 | Password not visible in log | [ ] |
| 4 | Gateway restarted | [ ] |
| 5 | API test successful | [ ] |
| Problem | Cause | Solution |
| ——— | ——- | ———- |
Database not found | Wrong database | Check database name |
Login failed | Wrong password | Check credentials |
Connection refused | Firewall blocking | Open port 1433/5432/3306 |
Provider not supported | Wrong provider name | sqlserver, sqlite, postgresql, mysql |
JSON parse error | Syntax error | Validate JSON (jsonlint.com) |
Never log passwords in plain text!
Use environment variables for credentials:
"ConnectionString": "Server=sql01;Database=ProdDB;User Id=${DB_USER};Password=${DB_PASS}"
« <- Start Server | -> Health Check »
Wolfgang van der Stille @ EMSR DATA d.o.o. - Data Gateway Professional