Supametas.AI
Official website
简体中文
简体中文
  • 欢迎来到 Supametas.AI
  • 云服务
    • Supametas.AI 云服务
      • 详细价格表对比
    • 指南
      • 创建数据集
      • 导入元数据
        • 抓取网页数据
        • 导入本地文本处理
        • 导入本地图片处理
        • 导入本地音频处理
        • 导入本地视频处理
      • 清洗数据查询
      • 导出清洗数据
      • 数据集配置
  • 开发者
    • 接入流程
    • 创建API-Key
    • 标准请求和响应
    • 业务接口
      • 导入文本文件
      • 导入网页任务
      • 导入图像文件
      • 导入音频文件
      • 导入视频文件
      • 查看导入任务详情
      • 删除处理文件任务
    • Webhook
    • 错误编码表
    • Demo
  • 其他
    • 社区
    • 寻求支持
由 GitBook 提供支持
在本页
  1. 开发者

Demo

<!-- Add Maven dependency -->
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>${fast.version}</version>
</dependency>
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;

import com.fasterxml.jackson.databind.ObjectMapper;

public class WebhookTest {

    public static void main(String[] args) {
        try {
            // Define the URL for the request
            String url = "https://xxx/open/set-webhook"; // Replace with the actual API endpoint
            
            // Create an HttpClient
            HttpClient client = HttpClient.newHttpClient();
            
            // Create a SetWebHookRequest object
            SetWebHookRequest setWebHookRequest = new SetWebHookRequest();
            setWebHookRequest.setUrl("https://your-webhook-url.com");
            
            // Convert the request object into a JSON string
            ObjectMapper objectMapper = new ObjectMapper();
            String requestBody = objectMapper.writeValueAsString(setWebHookRequest);
            
            // Construct HTTP request
            HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Access-Key", "your-access-key") // Replace with the actual access key
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(requestBody, StandardCharsets.UTF_8))
                .build();
            
            // Send a request and receive a response
            HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
            
            // Print the response result
            System.out.println("Response status code: " + response.statusCode());
            System.out.println("Response body: " + response.body());
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

// Definition of the SetWebHookRequest class
class SetWebHookRequest {
    private String url;

    // Getter and Setter methods
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

type SetWebHookRequest struct {
    URL string `json:"url"`
}

func main() {
    // URL of the request
    url := "https://xxx/open/set-webhook" // Replace with the actual API endpoint
    accessKey := "your-access-key"       // Replace with the actual access key

    // Create a SetWebHookRequest object
    requestBody := SetWebHookRequest{
        URL: "https://your-webhook-url.com",
    }

    // Convert an object to a JSON string
    jsonData, err := json.Marshal(requestBody)
    if err != nil {
        fmt.Println("Error marshaling JSON:", err)
        return
    }

    // Construct request
    req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    if err != nil {
        fmt.Println("Error creating request:", err)
        return
    }

    // Set request headers
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Access-Key", accessKey)

    // Send a request
    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Error sending request:", err)
        return
    }
    defer resp.Body.Close()

    // Print the response
    fmt.Println("Response Status:", resp.Status)
    fmt.Println("Response Headers:", resp.Header)
}
import requests
import json

# URL of the request
url = "https://xxx/open/set-webhook"  # Replace with the actual API endpoint
access_key = "your-access-key"       # Replace with the actual access key

# Create a SetWebHookRequest object
set_webhook_request = {
    "url": "https://your-webhook-url.com"
}

# Convert the request object into a JSON string
request_body = json.dumps(set_webhook_request)

# Send a request
headers = {
    "Content-Type": "application/json",
    "Access-Key": access_key
}
response = requests.post(url, headers=headers, data=request_body)

# Print the response result
print("Response Status Code:", response.status_code)
print("Response Body:", response.text)
require 'net/http'
require 'uri'
require 'json'
require 'openssl'

# URL of the request
url = 'https://xxx/open/set-webhook'  # Replace with the actual API endpoint
access_key = 'your-access-key'        # Replace with the actual access key

# Create a SetWebHookRequest object
set_webhook_request = {
  url: 'https://your-webhook-url.com'
}

# Convert the request object into a JSON string
request_body = set_webhook_request.to_json

# Create a URI object
uri = URI.parse(url)

# Construct HTTPS request
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER

# Construct the request
request = Net::HTTP::Post.new(uri.request_uri, { 'Content-Type' => 'application/json', 'Access-Key' => access_key })

# Configure request body
request.body = request_body

# Send a request and receive a response
response = http.request(request)

# Print the response result
puts "Response Status Code: #{response.code}"
puts "Response Body: #{response.body}"
上一页错误编码表下一页社区

最后更新于4个月前