Appearance
修改客户公海自定义组件数据
请求信息
- 接口:
/agent-api/user/{user_id}/customer/components - 请求方式:
PUT
路由参数
| 参数 | 类型 | 示例 | 解释 | 必填 |
|---|---|---|---|---|
| user_id | string | 5832d184-dd53-42a0-8ace-0bf8d660f4cc | 用户 id | 是 |
请求参数
| 参数 | 类型 | 示例 | 解释 | 必填 |
|---|---|---|---|---|
| filter_type | string | "id" | 筛选类型 | 是 |
| data | array | [] | 客户公海数据列表 | 是 |
| data.*.filter | string | "628b8c90-..." | 筛选值(客户公海 id) | 是 |
| data.*.components | array | [] | 自定义组件列表 | 是 |
| data..components..id | string | "c2125633-..." | 自定义组件 id | 是 |
| data..components..value | string | "组件值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": []
}