Supametas.AI
Official website
English
English
  • Welcome to Supametas.AI
  • Cloud Service
    • Supametas.AI Cloud Service
      • Detailed Pricing Comparison
    • Guide
      • Create Dataset
      • Import Metadata
        • Fetching webpage data
        • Importing local text processing
        • Importing local image processing
        • Importing local audio processing
        • Importing local video processing
      • Cleaning data query
      • Export Cleaned Data
      • Dataset Configuration
  • Developer
    • Integration Process
    • Create API Key
    • Standard Request and Response
    • API
      • Import Text File
      • Import Web Page Task
      • Import Image Files
      • Import Audio Files
      • Import Video Files
      • View Import Task Details
      • Delete File Processing Task
    • Webhook
    • Error Code
    • Demo
  • Other
    • Community
    • Technical Support
Powered by GitBook
On this page
  1. Developer

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}"
PreviousError CodeNextCommunity

Last updated 4 months ago