You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求协助:将指定HTTP请求转换为cURL与PowerShell命令

Slack API请求转cURL和PowerShell命令修正

原始HTTP请求

POST /api/users.profile.set
Host: slack.com
Content-type: application/json; charset=utf-8
Authorization: bearer_token
{
    "profile": {
        "status_text": "Eating some french fries from the frituur",
        "status_emoji": ":fries:"
    }
}

修正后的cURL命令

你原命令中status_emoji的双引号未转义,存在语法错误,同时补充了与原始请求一致的字符编码头,修正后命令如下:

curl 'https://slack.com/api/users.profile.set' \
--header 'Authorization: bearer_token' \
--header 'Content-Type: application/json; charset=utf-8' \
--data-raw "{
   \"profile\": {
        \"status_text\": \"Eating some french fries from the frituur\",
        \"status_emoji\": \":fries:\"
    }
}"
  • 需将bearer_token替换为你的实际Slack API令牌
  • 确保所有双引号转义正确,避免JSON格式报错

修正后的PowerShell命令

你原命令缺少请求体参数,需添加JSON格式的请求内容,修正后命令如下:

# 构造请求体并转为JSON格式
$requestBody = @{
    profile = @{
        status_text = "Eating some french fries from the frituur"
        status_emoji = ":fries:"
    }
} | ConvertTo-Json

Invoke-WebRequest -Headers @{"Authorization" = "bearer_token"} `
                  -Method POST `
                  -Uri "https://slack.com/api/users.profile.set" `
                  -ContentType "application/json; charset=utf-8" `
                  -Body $requestBody
  • 用哈希表转JSON的方式避免手动转义双引号的繁琐
  • 替换bearer_token为你的实际API令牌

内容的提问来源于stack exchange,提问作者shadowz1337

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 22:45:36