将HTTP请求转换为Powershell和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) 
```

最新更新