Appearance
公海组件修改
接口信息
- 接口:
/agent-api/user/{user_id}/component/{component_id} - 请求方式:
PUT
路由参数
| 参数 | 类型 | 示例 | 解释 | 必填 |
|---|---|---|---|---|
| user_id | string | 5832d184-dd53-42a0-8ace-0bf8d660f4cc | 用户 id(主账号) | 是 |
| component_id | string | 12d81f68-4ae2-430a-bd57-8e2f565fc866 | 组件 id | 是 |
请求参数
| 参数 | 类型 | 示例 | 解释 | 必填 |
|---|---|---|---|---|
| name | string | 组件 | 组件名称 (存在唯一性) | 否 |
| type | string | text | 组件类型 text-文本 date-日期 number-数字 | 否 |
| sort | int | 0 | 排序 | 否 |
| validate | array | ["sometimes"] | 必填开关 sometimes-非必填 required-必填 | 否 |
| status | bool | true | 组件状态 | 否 |
请求示例
cURL
curl -X PUT "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/component/12d81f68-4ae2-430a-bd57-8e2f565fc866" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"name": "Life",
"type": "number",
"sort": 0,
"validate": ["sometimes"],
"status": false
}'Go
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
jsonData := []byte(`{
"name": "Life",
"type": "number",
"sort": 0,
"validate": ["sometimes"],
"status": false
}`)
client := &http.Client{}
req, _ := http.NewRequest("PUT", "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/component/12d81f68-4ae2-430a-bd57-8e2f565fc866", bytes.NewBuffer(jsonData))
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer YOUR_TOKEN")
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}JavaScript
const response = await fetch("https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/component/12d81f68-4ae2-430a-bd57-8e2f565fc866", {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN"
},
body: JSON.stringify({
name: "Life",
type: "number",
sort: 0,
validate: ["sometimes"],
status: false
})
});
const data = await response.json();
console.log(data);Java
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
public class Main {
public static void main(String[] args) throws Exception {
URL url = new URL("https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/component/12d81f68-4ae2-430a-bd57-8e2f565fc866");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("PUT");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Authorization", "Bearer YOUR_TOKEN");
conn.setDoOutput(true);
String jsonInput = "{\"name\":\"Life\",\"type\":\"number\",\"sort\":0,\"validate\":[\"sometimes\"],\"status\":false}";
try (OutputStream os = conn.getOutputStream()) {
byte[] input = jsonInput.getBytes("utf-8");
os.write(input, 0, input.length);
}
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = br.readLine()) != null) {
response.append(line);
}
br.close();
System.out.println(response.toString());
}
}PHP
<?php
$ch = curl_init();
$data = [
"name" => "Life",
"type" => "number",
"sort" => 0,
"validate" => ["sometimes"],
"status" => false
];
curl_setopt($ch, CURLOPT_URL, "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/component/12d81f68-4ae2-430a-bd57-8e2f565fc866");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer YOUR_TOKEN"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>Python
import requests
import json
url = "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/component/12d81f68-4ae2-430a-bd57-8e2f565fc866"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN"
}
data = {
"name": "Life",
"type": "number",
"sort": 0,
"validate": ["sometimes"],
"status": False
}
response = requests.put(url, headers=headers, data=json.dumps(data))
print(response.json())C++
#include <iostream>
#include <curl/curl.h>
#include <string>
int main() {
CURL* 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 json_data = R"({"name":"Life","type":"number","sort":0,"validate":["sometimes"],"status":false})";
curl_easy_setopt(curl, CURLOPT_URL, "https://ai.api.longlonglong.cn/agent-api/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/component/12d81f68-4ae2-430a-bd57-8e2f565fc866");
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_data.c_str());
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return 0;
}字段说明
| 字段 | 说明 |
|---|---|
| name | 组件名称(存在唯一性) |
| type | 组件类型:text/number/date |
| sort | 排序(最大不能超过100) |
| validate | 验证规则:required必填,sometimes非必填 |
| status | 状态:true开启,false关闭 |
返回结果
json
{
"code": 200,
"status": "success",
"message": "修改客户组件成功",
"data": []
}