在 Manus 中运行任何 Skill
一键导入
一键导入
一键在 Manus 中运行任何 Skill
开始使用http
星标0
分支0
更新时间2026年4月30日 21:59
Rules for writing HTTP requests and responses in s&box
安装
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
SKILL.md
readonly菜单
Rules for writing HTTP requests and responses in s&box
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | http |
| description | Rules for writing HTTP requests and responses in s&box |
Http static class from Sandbox namespaceusing Sandbox;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Text.Json;
// All HTTP methods are static on the Http class
var response = await Http.RequestAsync("https://api.example.com/data");
GET Requests:
// Simple GET
var response = await Http.RequestAsync("https://api.example.com/endpoint");
// GET with query parameters (build URL manually)
var url = "https://api.example.com/search?q=test&limit=10";
var response = await Http.RequestAsync(url);
POST Requests:
// POST with JSON body
var json = JsonSerializer.Serialize(myObject);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await Http.RequestAsync("https://api.example.com/create",
method: "POST",
content: content);
// POST with form data
var formData = new Dictionary<string, string>
{
{ "name", "value" },
{ "key", "data" }
};
var json = JsonSerializer.Serialize(formData);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await Http.RequestAsync("https://api.example.com/form",
method: "POST",
content: content);
PUT/DELETE Requests:
// PUT request
var json = JsonSerializer.Serialize(updatedData);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await Http.RequestAsync("https://api.example.com/update/123",
method: "PUT",
content: content);
// DELETE request
var response = await Http.RequestAsync("https://api.example.com/delete/123",
method: "DELETE");
// Add custom headers
var headers = new Dictionary<string, string>
{
{ "Authorization", "Bearer your-token-here" },
{ "Content-Type", "application/json" },
{ "X-Custom-Header", "value" }
};
var response = await Http.RequestAsync("https://api.example.com/endpoint",
headers: headers);
var response = await Http.RequestAsync("https://api.example.com/data");
// Check status code
if (response.StatusCode == 200)
{
// Parse JSON response
var data = await response.Content.ReadFromJsonAsync<MyDataType>();
// Or get raw body
var rawBody = await response.Content.ReadAsStringAsync();
}
else
{
Log.Error($"Request failed with status {response.StatusCode}");
}
await with HTTP requests - they are asynchronous operationsasyncpublic async Task<MyData> FetchDataAsync()
{
var response = await Http.RequestAsync("https://api.example.com/data");
if (response.StatusCode == 200)
{
var data = await response.Content.ReadFromJsonAsync<MyData>();
return data;
}
return null;
}
try
{
var response = await Http.RequestAsync("https://api.example.com/data");
if (response.StatusCode >= 200 && response.StatusCode < 300)
{
// Success
var data = await response.Content.ReadFromJsonAsync<MyData>();
return data;
}
else
{
Log.Warning($"HTTP request failed: {response.StatusCode} - {response.Content}");
}
}
catch (Exception ex)
{
Log.Error($"HTTP request exception: {ex.Message}");
}
Reusable API Client:
public class ApiClient
{
private readonly string _baseUrl;
private readonly Dictionary<string, string> _defaultHeaders;
public ApiClient(string baseUrl, string apiKey)
{
_baseUrl = baseUrl;
_defaultHeaders = new Dictionary<string, string>
{
{ "Authorization", $"Bearer {apiKey}" },
{ "Content-Type", "application/json" }
};
}
public async Task<T> GetAsync<T>(string endpoint)
{
var response = await Http.RequestAsync($"{_baseUrl}/{endpoint}",
headers: _defaultHeaders);
if (response.StatusCode == 200)
{
return await response.Content.ReadFromJsonAsync<T>();
}
throw new Exception($"Request failed: {response.StatusCode}");
}
public async Task<T> PostAsync<T>(string endpoint, object data)
{
var json = JsonSerializer.Serialize(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await Http.RequestAsync($"{_baseUrl}/{endpoint}",
method: "POST",
headers: _defaultHeaders,
content: content);
if (response.StatusCode >= 200 && response.StatusCode < 300)
{
return await response.Content.ReadFromJsonAsync<T>();
}
throw new Exception($"Request failed: {response.StatusCode}");
}
}
Usage:
var client = new ApiClient("https://api.example.com", "your-api-key");
var data = await client.GetAsync<MyData>("endpoint");
response.StatusCode - HTTP status code (200, 404, 500, etc.) - use HttpStatusCode enum for comparisonresponse.Content - HttpContent object containing the response bodyawait response.Content.ReadFromJsonAsync<T>() to parse JSON responsesawait response.Content.ReadAsStringAsync() to get raw string contentresponse.StatusCode using enum comparisons: response.StatusCode == HttpStatusCode.OK or numeric ranges: response.StatusCode >= 200 && response.StatusCode < 300