API Connections
Manage connections to external APIs, including Microsoft Dynamics 365 Business Central (Navision).
Overview
API Connections store credentials and configuration for external services that GSM Middleware integrates with. Currently supported:
- Business Central (Navision) - OData API for order export, inventory, and verification
- Basic Auth - Username/password authentication
- OAuth 2.0 - Token-based authentication (for future integrations)
Location: WordPress Admin → GSM Middleware → API Connections
Connection Types
Basic Authentication
Standard username/password authentication:
Fields:
- Name: Descriptive name (e.g., "Navision Production")
- Environment:
live,beta,dev, orlocal - URL: API base URL (e.g.,
https://api.bc.example.com:7048/BC180/ODataV4/Company('Company%20Name')) - Username: API username
- Password: API password
- Active: Mark as active connection
OAuth 2.0 Authentication
Token-based authentication (for future use):
Fields:
- Client ID: OAuth application ID
- Client Secret: OAuth application secret
- Tenant ID: Azure AD tenant ID (for Microsoft services)
- Token URL: OAuth token endpoint
- Scopes: Required OAuth scopes
Managing Connections
Add a New Connection
- Navigate to GSM Middleware → API Connections
- Click "Add Connection" button
- Fill in the form:
- Name:
Navision Production - Type:
basic - Environment:
live - URL: Your OData endpoint
- Username: API username
- Password: API password
- Name:
- Click "Test Connection"
- If successful, click "Save"
Edit Existing Connection
- Find the connection in the list
- Click "Edit"
- Modify fields as needed
- Click "Test Connection" to verify
- Click "Save"
Activate a Connection
Only one connection per environment can be active at a time.
- Find the connection
- Click "Activate"
- Other connections for that environment are automatically deactivated
Delete a Connection
⚠️ Warning: Deleting an active connection will break sync operations!
- Click "Delete" next to the connection
- Confirm the deletion
- Connection is permanently removed
Test Connection
Verify credentials before saving:
- Fill in connection details
- Click "Test Connection"
- Wait for result:
- ✅ Success: "Connection successful - API responding"
- ❌ Failure: Error message with details
Common errors:
401 Unauthorized: Wrong username/password404 Not Found: Incorrect URLConnection timeout: Network/firewall issueSSL Error: Certificate problem
Business Central Setup
OData URL Format
https://[server]:[port]/[instance]/ODataV4/Company('[company-name]')
Example:
https://api.bc.example.com:7048/BC180/ODataV4/Company('MyCompany')
URL Encoding:
- Spaces:
%20 - Apostrophes:
%27 - Example:
Company('ABC Company')→Company('ABC%20Company')
Required Permissions
The API user must have permissions to:
- Read items (for inventory sync)
- Create sales orders (for BC export)
- Read sales shipments (for tracking sync)
- Read item status codes
Creating API User in Business Central
- Open Business Central
- Go to Users (search "Users")
- Click New
- Fill in details:
- User Name:
api_user_gsm - Full Name:
GSM Middleware API
- User Name:
- Assign permissions:
- SUPER (for testing)
- Custom permission set (for production)
- Enable Web Services Access
- Set password
- Save
Web Services Configuration
Ensure OData endpoints are published:
- Go to Web Services
- Verify these are published:
Item(Page 31)SalesOrders(Page 42)SalesShipments(Page 143)
Environment Management
Multiple Environments
You can configure multiple environments:
| Environment | Purpose | Example |
|---|---|---|
| live | Production system | Main BC instance |
| beta | Staging/testing | Pre-production BC |
| dev | Development | Development BC |
| local | Local testing | Local BC instance |
Environment Switching
Switch between environments without changing configuration:
- Go to API Connections
- Click "Activate" on desired environment
- All sync operations now use that connection
Test vs. Production
Configure separate connections for testing:
Production:
- Environment:
live - URL:
https://bc-prod.example.com/... - Active: ✅ (during normal operations)
Testing:
- Environment:
beta - URL:
https://bc-test.example.com/... - Active: ✅ (when testing)
Security Best Practices
Password Management
- Use strong, unique passwords
- Rotate credentials regularly (every 90 days)
- Never share credentials
- Use dedicated API users (don't use personal accounts)
Access Control
- Limit API user permissions to minimum required
- Use read-only access where possible
- Monitor API access logs in Business Central
Network Security
- Use HTTPS only (never HTTP)
- Configure firewall rules to restrict access
- Consider VPN for additional security
- Use IP whitelisting if available
Credential Storage
All credentials are:
- Encrypted at rest in the database
- Never logged or displayed in full
- Transmitted over HTTPS only
- Accessible only to users with
manage_gsm_middlewarecapability
Connection Status
Status Indicators
- 🟢 Connected: Last test successful
- 🟡 Warning: Connection slow or intermittent
- 🔴 Error: Connection failed
- ⚪ Inactive: Connection disabled
Last Tested
Shows when connection was last verified:
- Just now: < 1 minute ago
- 5 minutes ago: Recent test
- 2 hours ago: May need retesting
- Never: New connection, not tested yet
Active Badge
- ✅ Active: Currently in use
- ⭕ Inactive: Not in use
Troubleshooting
Connection Test Fails
401 Unauthorized
Causes:
- Wrong username or password
- User account disabled in BC
- User lacks Web Services Access
Solutions:
- Verify credentials in Business Central
- Check user is active
- Enable Web Services Access
- Reset password if needed
404 Not Found
Causes:
- Wrong URL
- Wrong company name
- Web service not published
Solutions:
- Verify URL format
- Check company name encoding
- Publish required web services
- Test URL in browser
Connection Timeout
Causes:
- Network/firewall blocking request
- BC server down or slow
- Wrong port number
Solutions:
- Check firewall rules
- Verify BC is running
- Test with telnet:
telnet bc-server.com 7048 - Check port number in URL
SSL Certificate Error
Causes:
- Self-signed certificate
- Expired certificate
- Certificate hostname mismatch
Solutions:
- Install valid SSL certificate
- Renew expired certificate
- Update CA certificates:
sudo update-ca-certificates
Connection Works But Operations Fail
Check:
- API user permissions in BC
- Web services are published
- Required objects exist
- BC maintenance window (Sunday 19:00 - Monday 04:00 UTC)
Can't Save Connection
Check:
- User has
manage_gsm_middlewarecapability - All required fields filled in
- No JavaScript errors in browser console
- Database connection is working
API Connection Settings
Global Settings
Configure in Settings page:
- Connection Timeout: Max seconds to wait for response (default: 30)
- Retry Attempts: Number of retries on failure (default: 3)
- Retry Delay: Seconds between retries (default: 5)
Per-Connection Settings
Some settings are per-connection:
- Rate Limiting: Max requests per minute (for APIs with limits)
- Batch Size: Records per request (for bulk operations)
- Timeout Override: Custom timeout for slow endpoints
Next Steps
- Settings - Configure global plugin settings
- BC Export Setup - Configure Business Central export
- Troubleshooting - Solve connection issues