Appearance
任务暂停
接口信息
- 接口:
/agent-api/new/user/{user_id}/task_stop/{task_id} - 请求方式:
PUT
路由参数
| 参数 | 类型 | 示例 | 解释 | 必填 |
|---|---|---|---|---|
| user_id | string | 5832d184-dd53-42a0-8ace-0bf8d660f4cc | 用户 id(主账号) | 是 |
| task_id | string | f232d184-dd54-42a0-8ace-0bf8d660f4cc | 任务 id | 是 |
请求参数
| 参数 | 类型 | 示例 | 解释 | 必填 |
|---|---|---|---|---|
| sub_user_id | string | 876e5d57-fd76-4109-8b15-6726f1ec2dfa | 子账户 id(传递此参数则是对子账户操作) | 否 |
请求示例
cURL
curl -X PUT "https://ai.api.longlonglong.cn/agent-api/new/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/task_stop/f232d184-dd54-42a0-8ace-0bf8d660f4cc" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN"Go
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://ai.api.longlonglong.cn/agent-api/new/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/task_stop/f232d184-dd54-42a0-8ace-0bf8d660f4cc"
req, _ := http.NewRequest("PUT", url, nil)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_TOKEN")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}JavaScript
const axios = require('axios');
axios.put('https://ai.api.longlonglong.cn/agent-api/new/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/task_stop/f232d184-dd54-42a0-8ace-0bf8d660f4cc', {}, {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error);
});Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://ai.api.longlonglong.cn/agent-api/new/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/task_stop/f232d184-dd54-42a0-8ace-0bf8d660f4cc";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer YOUR_TOKEN")
.PUT(HttpRequest.BodyPublishers.noBody())
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}PHP
<?php
$url = 'https://ai.api.longlonglong.cn/agent-api/new/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/task_stop/f232d184-dd54-42a0-8ace-0bf8d660f4cc';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
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
url = 'https://ai.api.longlonglong.cn/agent-api/new/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/task_stop/f232d184-dd54-42a0-8ace-0bf8d660f4cc'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
}
response = requests.put(url, headers=headers)
print(response.json())C++
#include <iostream>
#include <string>
#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) {
curl_easy_setopt(curl, CURLOPT_URL, "https://ai.api.longlonglong.cn/agent-api/new/user/5832d184-dd53-42a0-8ace-0bf8d660f4cc/task_stop/f232d184-dd54-42a0-8ace-0bf8d660f4cc");
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer YOUR_TOKEN");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
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;
}注意事项
新版外呼2.0的任务关闭、开启逻辑与外呼2.0不一样,会存在多个运行中的实例,在运行实例没有完全停止的情况下,不能删除任务号码。
成功返回结果
json
{
"status": "success",
"code": 200,
"message": "停止任务成功"
}