diff --git a/test_api.php b/test_api.php new file mode 100644 index 0000000..200a536 --- /dev/null +++ b/test_api.php @@ -0,0 +1,95 @@ + 'Test Ticket from PHP Script', + 'description' => 'This is a test ticket to debug the API', + 'priority' => '3', + 'category' => 'Test', + 'type' => 'Issue', + 'status' => 'Open' +]; + +echo "Sending test ticket...\n"; +echo "URL: http://10.10.10.45/create_ticket_api.php\n\n"; + +// Make the API call +$ch = curl_init('http://10.10.10.45/create_ticket_api.php'); +curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'Content-Type: application/json', + 'Authorization: Bearer ' . $apiKey +]); +curl_setopt($ch, CURLOPT_POST, 1); +curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($testTicket)); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_VERBOSE, true); +curl_setopt($ch, CURLOPT_TIMEOUT, 10); + +// Capture verbose output +$verbose = fopen('php://temp', 'w+'); +curl_setopt($ch, CURLOPT_STDERR, $verbose); + +$response = curl_exec($ch); +$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); +$curlError = curl_error($ch); + +// Get verbose output +rewind($verbose); +$verboseLog = stream_get_contents($verbose); +fclose($verbose); + +curl_close($ch); + +echo "HTTP Code: $httpCode\n"; +echo "cURL Error: " . ($curlError ?: 'None') . "\n\n"; + +echo "=== Raw Response ===\n"; +echo "Length: " . strlen($response) . " bytes\n"; +echo "Content:\n"; +var_dump($response); +echo "\n"; + +if ($response) { + echo "=== Decoded JSON ===\n"; + $decoded = json_decode($response, true); + if ($decoded === null) { + echo "ERROR: Failed to decode JSON\n"; + echo "JSON Error: " . json_last_error_msg() . "\n"; + } else { + print_r($decoded); + } +} else { + echo "ERROR: Empty response received\n"; +} + +echo "\n=== cURL Verbose Log ===\n"; +echo $verboseLog; +echo "\n";