Troubleshooting
Troubleshooting Guide
This guide helps you diagnose and resolve common issues when using the Spreetail Channel Integration API.
Common Issues
Authentication Problems
Issue: "Invalid credentials" error
Symptoms:
- Receiving
401 Unauthorizedwith "Invalid credentials" message - Cannot authenticate even with correct-looking credentials
Possible Causes:
- Incorrect Client ID or Client Secret
- Credentials not activated
- Account suspended or disabled
- Typo in credentials
Solutions:
- Verify Credentials: Double-check Client ID and Client Secret for typos
- Check Account Status: Contact [email protected] to verify account status
- Test with cURL: Use cURL to isolate the issue:
curl -X POST 'https://api.spreetaileu.com/api/api/v1/auth/login' \ -H 'Content-Type: application/json' \ -d '{"client_id": "YOUR_ID", "client_secret": "YOUR_SECRET"}' - Check Environment Variables: Ensure environment variables are loaded correctly
Issue: Token expires immediately
Symptoms:
- Token works for a few requests then fails
- Receiving 401 errors shortly after authentication
Possible Causes:
- Token not being cached properly
- Multiple instances requesting new tokens
- Clock skew between client and server
Solutions:
- Implement Token Caching: Cache tokens and reuse them
- Check System Clock: Ensure system clock is synchronized
- Reduce Token Requests: Don't request new token for every API call
Order Creation Issues
Issue: "ReferenceNumber is required" error
Symptoms:
- Receiving 400 error when creating order
- Error message mentions missing ReferenceNumber
Solutions:
- Check Request Body: Ensure
ReferenceNumberfield is included - Verify JSON Structure: Check that the request is valid JSON
- Check Field Name: Ensure exact field name (case-sensitive)
# Correct
order = {
"ReferenceNumber": "ORD-001", # Correct
...
}
# Incorrect
order = {
"reference_number": "ORD-001", # Wrong field name
"referenceNumber": "ORD-001", # Wrong case
...
}Issue: "Order with ReferenceNumber already exists"
Symptoms:
- Receiving 409 Conflict error
- Error indicates duplicate reference number
Solutions:
- Check Previous Orders: Verify if order was already created
- Use Unique Reference Numbers: Implement unique reference number generation
- Handle Gracefully: If order exists, fetch it instead of creating new one
def create_order_safely(order_data):
try:
return create_order(order_data)
except APIError as e:
if e.status_code == 409:
# Order exists, fetch it
reference = order_data['ReferenceNumber']
return get_order_by_reference(reference)
raiseIssue: "Invalid date format" error
Symptoms:
- 400 error with date format message
- Dates not being accepted
Solutions:
- Use ISO 8601 Format:
YYYY-MM-DDTHH:mm:ssZ - Use UTC Timezone: Always use UTC (Z suffix)
- Validate Before Sending: Check date format before API call
from datetime import datetime, timezone
# Correct
date_str = datetime.now(timezone.utc).isoformat().replace('+00:00', 'Z')
# Result: "2025-01-15T10:30:00Z"
# Incorrect formats
"2025-01-15" # Missing time
"2025-01-15 10:30:00" # Wrong format
"2025/01/15T10:30:00Z" # Wrong date separatorInventory Issues
Issue: SKU not found
Symptoms:
- Empty results when querying inventory
- SKU exists but API returns no results
Possible Causes:
- SKU doesn't exist in system
- SKU belongs to different client
- SKU is inactive or deleted
Solutions:
- Verify SKU: Check SKU spelling and format
- Check Client Mapping: Ensure SKU is associated with your client
- Contact Support: If SKU should exist, contact [email protected]
Issue: Inventory quantity mismatch
Symptoms:
- API shows different quantity than expected
- Quantity doesn't match warehouse system
Solutions:
- Check Last Updated: Review
last_updatedtimestamp - Account for Reserved: Remember
quantity = on_hand - reserved - Check Timing: Inventory updates may have slight delay
- Verify Client: Ensure you're checking correct client's inventory
Network and Connection Issues
Issue: Connection timeout
Symptoms:
- Requests timing out
- No response from API
Solutions:
- Check Network: Verify internet connectivity
- Increase Timeout: Set appropriate timeout values
- Retry Logic: Implement retry with exponential backoff
- Check Firewall: Ensure API domain is not blocked
# Good: Configure timeouts
response = requests.post(
url,
json=data,
timeout=(5, 30) # (connect timeout, read timeout)
)Issue: SSL/TLS errors
Symptoms:
- SSL certificate verification errors
- Connection refused errors
Solutions:
- Update Certificates: Ensure system has latest CA certificates
- Check API URL: Verify using correct HTTPS URL
- Update Libraries: Update requests/urllib3 libraries
Rate Limiting Issues
Issue: "Rate limit exceeded" error
Symptoms:
- Receiving 429 Too Many Requests
- Requests being rejected
Solutions:
- Implement Rate Limiting: Track request rate
- Use Exponential Backoff: Wait before retrying
- Batch Requests: Combine multiple operations when possible
- Request Higher Limits: Contact support for increased limits if needed
# Good: Rate limit handling
if response.status_code == 429:
retry_after = int(response.headers.get('Retry-After', 60))
time.sleep(retry_after)
# Retry requestDebugging Tips
Enable Verbose Logging
import logging
import http.client
# Enable debug logging
logging.basicConfig(level=logging.DEBUG)
# Enable HTTP connection logging
http.client.HTTPConnection.debuglevel = 1Log Request/Response Details
def log_request_details(request, response):
logger.debug(f"Request URL: {request.url}")
logger.debug(f"Request Headers: {dict(request.headers)}")
logger.debug(f"Request Body: {request.body}")
logger.debug(f"Response Status: {response.status_code}")
logger.debug(f"Response Headers: {dict(response.headers)}")
logger.debug(f"Response Body: {response.text}")Test with cURL
Use cURL to test API calls directly:
# Test authentication
curl -v -X POST 'https://api.spreetaileu.com/api/api/v1/auth/login' \
-H 'Content-Type: application/json' \
-d '{"client_id": "YOUR_ID", "client_secret": "YOUR_SECRET"}'
# Test order creation
curl -v -X POST 'https://api.spreetaileu.com/api/api/v1/outbound' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d @order.jsonValidate JSON
Ensure request bodies are valid JSON:
import json
def validate_json(data):
try:
json.dumps(data)
return True
except (TypeError, ValueError) as e:
print(f"Invalid JSON: {e}")
return FalseGetting Help
Information to Include
When contacting support, include:
- Error Message: Exact error message and status code
- Request Details: Endpoint, method, headers (without tokens)
- Request Body: Request payload (sanitized)
- Response: Full response body
- Timestamp: When the error occurred
- Client ID: Your client identifier (not secret)
- Steps to Reproduce: What you did before the error
Contact Support
Email: [email protected]
Subject Format: [API Support] - [Brief Description]
Example:
Subject: [API Support] - 401 Unauthorized when creating order
Body:
Client ID: client-abc-123
Endpoint: POST /outbound
Error: 401 Unauthorized
Error Message: Invalid or expired token
Timestamp: 2025-01-15T10:30:00Z
Steps: Authenticated successfully, then tried to create order immediately
Quick Reference
Status Code Meanings
| Code | Meaning | Action |
|---|---|---|
| 200 | Success | Continue |
| 400 | Bad Request | Fix request data |
| 401 | Unauthorized | Refresh token or check credentials |
| 403 | Forbidden | Check permissions |
| 404 | Not Found | Verify resource exists |
| 409 | Conflict | Handle duplicate |
| 429 | Rate Limited | Wait and retry |
| 500 | Server Error | Retry with backoff |
| 503 | Service Unavailable | Retry later |
Common Field Requirements
- ReferenceNumber: Required, unique per client, string
- Currency: Required, ISO 4217 code (EUR, GBP, USD)
- Dates: Required, ISO 8601 format with Z suffix
- OrderItems: Required, array with at least one item
- Addresses: Required, must include FullName, Address1, Town, PostCode, Country
Prevention
Pre-flight Checks
Before making API calls:
- ✅ Validate all required fields
- ✅ Check date formats
- ✅ Verify currency codes
- ✅ Ensure unique reference numbers
- ✅ Validate JSON structure
- ✅ Check authentication token validity
- ✅ Verify network connectivity
Monitoring
Set up monitoring for:
- Authentication failures
- Error rates by type
- Response times
- Rate limit usage
- Order creation success rate
Updated 1 day ago
