웹훅 전송 테스트
curl --request GET \
--url https://api.benzinga.com/api/v1/webhook/test \
--header 'Key: <api-key>'import requests
url = "https://api.benzinga.com/api/v1/webhook/test"
headers = {"Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Key: '<api-key>'}};
fetch('https://api.benzinga.com/api/v1/webhook/test', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.benzinga.com/api/v1/webhook/test",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.benzinga.com/api/v1/webhook/test"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.benzinga.com/api/v1/webhook/test")
.header("Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.benzinga.com/api/v1/webhook/test")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"status": "success"
}
{
"error": "Invalid destination URL"
}
{
"error": "Failed to deliver test payload to destination"
}
{
"ok": false,
"errors": [
{
"code": "auth_failed",
"id": "unauthorized",
"value": "Invalid or missing authentication token"
}
]
}
{
"ok": false,
"errors": [
{
"code": "no_data_found",
"id": "not_found",
"value": "No data found for the specified parameters"
}
]
}
{
"ok": false,
"errors": [
{
"code": "internal_server_error",
"id": "server_error",
"value": "An unexpected error occurred while processing your request"
}
]
}
웹훅 전송 테스트
이 엔드포인트는 테스트 데이터를 웹훅 엔드포인트로 전송하여 통합이 올바르게 동작하는지 확인할 수 있도록 합니다
GET
/
api
/
v1
/
webhook
/
test
웹훅 전송 테스트
curl --request GET \
--url https://api.benzinga.com/api/v1/webhook/test \
--header 'Key: <api-key>'import requests
url = "https://api.benzinga.com/api/v1/webhook/test"
headers = {"Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Key: '<api-key>'}};
fetch('https://api.benzinga.com/api/v1/webhook/test', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.benzinga.com/api/v1/webhook/test",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.benzinga.com/api/v1/webhook/test"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.benzinga.com/api/v1/webhook/test")
.header("Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.benzinga.com/api/v1/webhook/test")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"status": "success"
}
{
"error": "Invalid destination URL"
}
{
"error": "Failed to deliver test payload to destination"
}
{
"ok": false,
"errors": [
{
"code": "auth_failed",
"id": "unauthorized",
"value": "Invalid or missing authentication token"
}
]
}
{
"ok": false,
"errors": [
{
"code": "no_data_found",
"id": "not_found",
"value": "No data found for the specified parameters"
}
]
}
{
"ok": false,
"errors": [
{
"code": "internal_server_error",
"id": "server_error",
"value": "An unexpected error occurred while processing your request"
}
]
}
개요
통합 테스트
destination URL로 테스트 웹훅 페이로드를 전송합니다. 이 테스트 전송은 프로덕션 환경의 웹훅 전송과 동일한 형식과 재시도 로직을 따릅니다.
예상되는 사항
- 즉시 응답: 테스트 전송이 성공적으로 트리거되면 API는
200상태 코드를 반환합니다. - 테스트 페이로드: 웹훅 엔드포인트는 프로덕션 데이터와 동일한 형식의 테스트 페이로드를 수신합니다.
- 전송 헤더: 테스트 전송에는 프로덕션 전송과 마찬가지로
X-BZ-Delivery헤더가 포함됩니다.
통합 검증하기
- 웹훅 엔드포인트가 외부에서 접근 가능함
- 엔드포인트가 웹훅 페이로드 형식을 올바르게 파싱할 수 있음
- 엔드포인트가 적절한 상태 코드(성공 시 2xx)로 응답함
- 엔드포인트가 30초 타임아웃 내에 응답함
- 멱등성 로직이
X-BZ-Delivery헤더와 페이로드의id필드를 올바르게 처리함
모범 사례
- 먼저 운영 환경이 아닌 Webhook 엔드포인트로 테스트하세요
- 엔드포인트가
200또는204상태 코드로 응답하는지 확인하세요 - 로그 및 모니터링에서 테스트 전달이 기록되는지 확인하세요
- 중복 제거 로직이 테스트 전달 ID와 함께 정상적으로 동작하는지 확인하세요
- 일시적으로 오류 상태 코드를 반환하여 오류 시나리오를 테스트하세요
문제 해결
424 전달 오류
424 상태 코드를 받은 경우, 시스템이 테스트 페이로드를 대상 엔드포인트로 전달하지 못한 것입니다. 일반적인 원인은 다음과 같습니다:
- 대상 URL이 공개적으로 접근할 수 없음
- 대상 엔드포인트가 오류 상태 코드를 반환함
- 네트워크 연결 문제
- 대상 엔드포인트의 SSL/TLS 인증서 오류
400 잘못된 요청
destination은(는) 유효한 HTTPS URL이어야 합니다.version은(는)webhook/v1이어야 합니다.kind는 지원되는 이벤트 kind 중 하나여야 합니다(예:News/v1,Earnings/v1,Ratings/v1등).
{
"status": "success"
}
{
"error": "Invalid destination URL"
}
{
"error": "Failed to deliver test payload to destination"
}
{
"ok": false,
"errors": [
{
"code": "auth_failed",
"id": "unauthorized",
"value": "Invalid or missing authentication token"
}
]
}
{
"ok": false,
"errors": [
{
"code": "no_data_found",
"id": "not_found",
"value": "No data found for the specified parameters"
}
]
}
{
"ok": false,
"errors": [
{
"code": "internal_server_error",
"id": "server_error",
"value": "An unexpected error occurred while processing your request"
}
]
}
Authorizations
사용자의 Benzinga API 키
Query Parameters
테스트 데이터를 수신할 webhook 엔드포인트 url
API 버전(현재는 webhook/v1)
Available options:
webhook/v1 테스트 페이로드의 메시지 kind를 나타냅니다
Available options:
News/v1, Signals/v1, Earnings/v1, Ratings/v1, Dividends/v1, IPOs/v1, Guidance/v1, Splits/v1, OptionActivity/v1, Conference/v1, Economics/v1, Offerings/v1, MA/v1, Retail/v1, FDA/v1, WIIMs/v1, SECInsiderTransaction/v1, GovernmentTrade/v1 실서비스 환경에서 사용할 수 있도록 데이터를 변환하려면 토큰을 지정하세요
Response
성공 - 테스트 웹훅이 성공적으로 전송되었습니다
Example:
"success"
Was this page helpful?