簡體   English   中英

將 HTTP 請求轉換為 Powershell 和 cURL

[英]Convert HTTP request to Powershell and cURL

我正在嘗試將 HTTP 請求(我以前從未處理過)轉換為 cURL 和 Powershell 命令,但我無法在任何地方填寫空白。

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 'https://slack.com/api/users.profile.set' `
--header 'Authorization: bearer_token' `
--header 'Content-Type: application/json' `
--data-raw "{
   \"profile\": {
        \"status_text\": \"On Lunch\",
        \"status_emoji\": \":hamburger:\"
    }
}"

Invoke-WebRequest -Headers @{"Authorization" = "bearer_token"} `
                  -Method POST `
                  -Uri https://slack.com/api/users.profile.set `
                  -ContentType application/json


自己修好了。

curl -X POST 'https://slack.com/api/users.profile.set' `
-H 'Authorization: Bearer xoxp-xxxxxxxxxxxxxxxxx' `
-H 'Content-Type: application/json; charset=utf-8' `
-d '{
   \"profile\": {
        \"status_text\": \"Sick\",
        \"status_emoji\": \":sickpepe:\",
        \"status_expiration\": \"480\"
    }
}'
$body = @{
    profile = @{
        status_text  = "Eating some french fries from the frituur"
        status_emoji = ":fries:"
        status_expiration = 60
    }
}

Invoke-WebRequest -Headers @{"Authorization" = "Bearer xoxp-xxxxxxxxxxxxxxxxxxxx"} `
                  -Method POST `
                  -Uri https://slack.com/api/users.profile.set `
                  -ContentType 'application/json; charset=utf-8' `
                  -Body ($body|ConvertTo-Json) 
    ```

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM