# Trouble Ticket API Testing This guide provides specific testing approaches and examples for the Equinix Trouble Ticket API, building on the general [API Testing](https://docs.equinix.com/equinix-api/testing.md) principles. ## Trouble Ticket API Overview The Trouble Ticket API allows customers to programmatically interact with Equinix support, creating support tickets for service impacting issues across various categories: * Cross Connect issues * Network connectivity problems * Power-related incidents * Environmental concerns * Hardware failures * Security incidents * Managed Services support ## Trouble Ticket Problem Types The Trouble Ticket API supports various problem categories, each with specific problem codes: | Problem Category | Description | Example Codes | | ---------------- | ----------------------------------- | -------------------------- | | Cross Connect | Physical cable connection issues | cc01, cc02, cc03 | | Network | Network connectivity problems | net01, net02 | | Environment | HVAC, cooling, environmental issues | env01, env02, env03, env04 | | Hardware | Equipment and hardware failures | hdw01 | | Power | Power-related incidents | pwr01, pwr02 | | Security | Security access and badge issues | sec01, sec02 | | Managed Services | Managed service support requests | ms01-ms13 | | SmartView | SmartView monitoring issues | sv01-sv05 | ## Trouble Ticket Testing Workflow Before testing the Trouble Ticket API, ensure you have: * An Equinix Developer account with trouble ticket permissions * Valid API credentials (client ID and client secret) * Access to appropriate IBX locations and cages * Understanding of [API Authentication](https://docs.equinix.com/equinix-api/api-authentication.md) **Creating a Trouble Ticket Order** ``` import requests import json from datetime import datetime, timedelta # Setup authentication auth_url = "https://api.equinix.com/oauth2/v1/token" auth_payload = { "grant_type": "client_credentials", "client_id": "YOUR_CLIENT_ID", "client_secret": "YOUR_CLIENT_SECRET" } auth_response = requests.post(auth_url, data=auth_payload) token = auth_response.json()["access_token"] # Test creating a trouble ticket order base_url = "https://api.equinix.com" headers = { "Authorization": f"Bearer {token}", "Content-Type": "application/json" } # Example: Create a network connectivity trouble ticket request_payload = { "customerReferenceNumber": "TT-TEST-001", "ibxLocation": { "ibx": "CH1", "cages": [ { "cage": "CH1:05:000750", "accountNumber": "12345", "cabinets": [ "CH1:05:000750:01" ] } ] }, "serviceDetails": { "incidentDateTime": (datetime.utcnow() - timedelta(hours=1)).isoformat() + "Z", "problemCode": "net01", # Network connectivity issue "additionalDetails": "TEST: Network connectivity issue - API testing" }, "contacts": [ { "contactType": "ORDERING", "userName": "test_ordering_user" }, { "contactType": "NOTIFICATION", "userName": "test_notification_user" }, { "contactType": "TECHNICAL", "userName": "test_technical_user", "workPhone": "555-0123", "workPhonePrefToCall": "ANYTIME" } ] } create_response = requests.post( f"{base_url}/v1/orders/troubleticket", headers=headers, data=json.dumps(request_payload) ) # Verify response assert create_response.status_code == 201, f"Failed to create trouble ticket: {create_response.text}" order_number = create_response.json()["OrderNumber"] print(f"Successfully created trouble ticket order: {order_number}") ``` **Testing Location and Problem Type Validation** ``` # Test retrieving available locations locations_response = requests.get( f"{base_url}/v1/orders/troubleticket/locations", headers=headers ) assert locations_response.status_code == 200, f"Failed to retrieve locations: {locations_response.text}" locations = locations_response.json()["locations"] print(f"Available locations: {len(locations)}") # Test retrieving problem types types_response = requests.get( f"{base_url}/v1/orders/troubleticket/types", headers=headers ) assert types_response.status_code == 200, f"Failed to retrieve problem types: {types_response.text}" problem_types = types_response.json()["troubleTicketTypes"] print(f"Available problem types: {len(problem_types)}") ``` ## Testing Error Scenarios Always test error handling for your API implementation: ``` import requests import json from datetime import datetime, timedelta # Setup authentication auth_url = "https://api.equinix.com/oauth2/v1/token" auth_payload = { "grant_type": "client_credentials", "client_id": "YOUR_CLIENT_ID", "client_secret": "YOUR_CLIENT_SECRET" } auth_response = requests.post(auth_url, data=auth_payload) token = auth_response.json()["access_token"] # Prepare request base_url = "https://api.equinix.com" headers = { "Authorization": f"Bearer {token}", "Content-Type": "application/json" } # Test with invalid problem code invalid_payload = { "customerReferenceNumber": "TT-ERROR-TEST-001", "ibxLocation": { "ibx": "CH1", "cages": [{"cage": "CH1:05:000750", "accountNumber": "12345"}] }, "serviceDetails": { "incidentDateTime": (datetime.utcnow() - timedelta(hours=1)).isoformat() + "Z", "problemCode": "INVALID_CODE", # Invalid problem code "additionalDetails": "TEST: Invalid problem code test" }, "contacts": [ {"contactType": "ORDERING", "userName": "test_user"}, {"contactType": "NOTIFICATION", "userName": "test_user"} ] } error_response = requests.post( f"{base_url}/v1/orders/troubleticket", headers=headers, data=json.dumps(invalid_payload) ) # Verify error response assert error_response.status_code == 400, f"Expected error but got: {error_response.status_code}" error_data = error_response.json() assert "errors" in error_data, "Error response format not as expected" print("Successfully validated error handling for invalid problem code") print(json.dumps(error_data, indent=2)) ``` ## Best Practices for Trouble Ticket API Testing **Important Note:** The Equinix Trouble Ticket API is a production system that creates real support tickets. Always follow these testing best practices to ensure you don't create unintended operational work. 1. **Set up a dedicated testing account**: Request a separate account for testing if possible 2. **Use clearly marked test requests**: Always prefix descriptions with "TEST:" to help support staff identify test requests 3. **Use valid incident times**: Ensure incident date/time is properly formatted and not in the future 4. **Validate location access**: Use the locations endpoint to verify accessible IBX locations before creating tickets 5. **Test with valid problem codes**: Always validate problem codes using the types endpoint 6. **Include complete contact information**: Ensure all required contacts (ORDERING, NOTIFICATION) are provided 7. **Clean up test resources**: Work with support to close any test tickets immediately after creation 8. **Test error handling**: Verify proper error handling and response codes ## Automation Considerations When building automation around the Trouble Ticket API: * Implement proper error handling and retries for API failures * Build validation for required fields and data formats * Include audit logging of all ticket creation activities * Ensure incident times are accurately captured and formatted * Validate location and problem code information before submission * Consider implementing approval workflows for production ticket creation * Include comprehensive contact information for faster resolution ## Additional Resources * [Trouble Ticket API OpenAPI Specification](https://docs.equinix.com/api-catalog/troubleticketv1.md) * [General API Testing Guidelines](https://docs.equinix.com/equinix-api/testing.md) * [API Authentication Guide](https://docs.equinix.com/equinix-api/api-authentication.md)