Skip to content

公海组件修改

接口信息

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

路由参数

参数类型示例解释必填
user_idstring5832d184-dd53-42a0-8ace-0bf8d660f4cc用户 id(主账号)
component_idstring12d81f68-4ae2-430a-bd57-8e2f565fc866组件 id

请求参数

参数类型示例解释必填
namestring组件组件名称 (存在唯一性)
typestringtext组件类型 text-文本 date-日期 number-数字
sortint0排序
validatearray["sometimes"]必填开关 sometimes-非必填 required-必填
statusbooltrue组件状态

请求示例

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": []
}

基于 MIT 许可发布