Skip to content

修改客户公海自定义组件数据

请求信息

  • 接口: /agent-api/user/{user_id}/customer/components
  • 请求方式: PUT

路由参数

参数类型示例解释必填
user_idstring5832d184-dd53-42a0-8ace-0bf8d660f4cc用户 id

请求参数

参数类型示例解释必填
filter_typestring"id"筛选类型
dataarray[]客户公海数据列表
data.*.filterstring"628b8c90-..."筛选值(客户公海 id)
data.*.componentsarray[]自定义组件列表
data..components..idstring"c2125633-..."自定义组件 id
data..components..valuestring"组件值1"自定义组件值

请求示例

请求参数示例(JSON 格式):

json
{
    "filter_type":"id",
    "data": [
        {
            "filter": "628b8c90-9830-41e1-b953-a6eb36e50780", //客户公海id
            "components": [
                {
                    "id": "c2125633-d571-42d6-bbaa-5380090a2006", //自定义组件id
                    "value": "组件值1" //自定义组件值
                },
                {
                    "id": "5cab5498-53b5-4558-bbec-e7a2246498f5",
                    "value": "组件值2"
                }
            ]
        }
    ]
}
cURL
curl -X PUT "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/customer/components" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "filter_type": "id",
    "data": [
        {
            "filter": "628b8c90-9830-41e1-b953-a6eb36e50780",
            "components": [
                {"id": "c2125633-d571-42d6-bbaa-5380090a2006", "value": "组件值1"},
                {"id": "5cab5498-53b5-4558-bbec-e7a2246498f5", "value": "组件值2"}
            ]
        }
    ]
}'
Go
package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    url := "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/customer/components"

    body := `{
        "filter_type": "id",
        "data": [
            {
                "filter": "628b8c90-9830-41e1-b953-a6eb36e50780",
                "components": [
                    {"id": "c2125633-d571-42d6-bbaa-5380090a2006", "value": "组件值1"},
                    {"id": "5cab5498-53b5-4558-bbec-e7a2246498f5", "value": "组件值2"}
                ]
            }
        ]
    }`

    client := &http.Client{}
    req, _ := http.NewRequest("PUT", url, strings.NewReader(body))
    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Authorization", "Bearer YOUR_TOKEN")
    resp, _ := client.Do(req)
    defer resp.Body.Close()
    respBody, _ := io.ReadAll(resp.Body)
    fmt.Println(string(respBody))
}
JavaScript
const userId = "5832d184-dd53-42a0-8ace-0bf8d660f4cc";
const url = `https://ai.api.longlonglong.cn/agent-api/user/${userId}/customer/components`;

const requestBody = {
    filter_type: "id",
    data: [
        {
            filter: "628b8c90-9830-41e1-b953-a6eb36e50780",
            components: [
                { id: "c2125633-d571-42d6-bbaa-5380090a2006", value: "组件值1" },
                { id: "5cab5498-53b5-4558-bbec-e7a2246498f5", value: "组件值2" }
            ]
        }
    ]
};

const response = await fetch(url, {
    method: "PUT",
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer YOUR_TOKEN"
    },
    body: JSON.stringify(requestBody)
});
const data = await response.json();
console.log(data);
Java
import java.net.URI;
import java.net.http.*;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException, InterruptedException {
        String url = "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/customer/components";

        String requestBody = """
        {
            "filter_type": "id",
            "data": [
                {
                    "filter": "628b8c90-9830-41e1-b953-a6eb36e50780",
                    "components": [
                        {"id": "c2125633-d571-42d6-bbaa-5380090a2006", "value": "组件值1"},
                        {"id": "5cab5498-53b5-4558-bbec-e7a2246498f5", "value": "组件值2"}
                    ]
                }
            ]
        }
        """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .header("Content-Type", "application/json")
            .header("Authorization", "Bearer YOUR_TOKEN")
            .PUT(HttpRequest.BodyPublishers.ofString(requestBody))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
PHP
<?php

$userId = "5832d184-dd53-42a0-8ace-0bf8d660f4cc";

$requestBody = json_encode([
    'filter_type' => 'id',
    'data' => [
        [
            'filter' => '628b8c90-9830-41e1-b953-a6eb36e50780',
            'components' => [
                ['id' => 'c2125633-d571-42d6-bbaa-5380090a2006', 'value' => '组件值1'],
                ['id' => '5cab5498-53b5-4558-bbec-e7a2246498f5', 'value' => '组件值2']
            ]
        ]
    ]
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://ai.api.longlonglong.cn/agent-api/user/{$userId}/customer/components");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/json",
    "Authorization: Bearer YOUR_TOKEN"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Python
import requests

user_id = "5832d184-dd53-42a0-8ace-0bf8d660f4cc"
url = f"https://ai.api.longlonglong.cn/agent-api/user/{user_id}/customer/components"

request_body = {
    "filter_type": "id",
    "data": [
        {
            "filter": "628b8c90-9830-41e1-b953-a6eb36e50780",  # 客户公海id
            "components": [
                {"id": "c2125633-d571-42d6-bbaa-5380090a2006", "value": "组件值1"},  # 自定义组件id + 值
                {"id": "5cab5498-53b5-4558-bbec-e7a2246498f5", "value": "组件值2"}
            ]
        }
    ]
}

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN"
}

response = requests.put(url, json=request_body, headers=headers)
print(response.json())
C++
#include <iostream>
#include <curl/curl.h>

size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
    ((std::string*)userp)->append((char*)contents, size * nmemb);
    return size * nmemb;
}

int main() {
    CURL* curl;
    CURLcode res;
    std::string readBuffer;

    curl = curl_easy_init();
    if (curl) {
        struct curl_slist* headers = NULL;
        headers = curl_slist_append(headers, "Content-Type: application/json");
        headers = curl_slist_append(headers, "Authorization: Bearer YOUR_TOKEN");

        std::string url = "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/customer/components";

        std::string requestBody = R"({
            "filter_type": "id",
            "data": [
                {
                    "filter": "628b8c90-9830-41e1-b953-a6eb36e50780",
                    "components": [
                        {"id": "c2125633-d571-42d6-bbaa-5380090a2006", "value": "组件值1"},
                        {"id": "5cab5498-53b5-4558-bbec-e7a2246498f5", "value": "组件值2"}
                    ]
                }
            ]
        })";

        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, requestBody.c_str());
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);

        res = curl_easy_perform(curl);
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);

        std::cout << readBuffer << std::endl;
    }
    return 0;
}

返回示例

json
{
    "code": 200,
    "status": "success",
    "message": "修改客户公海组件成功",
    "data": []
}

基于 MIT 许可发布