У меня есть изображение, которое я пытаюсь опубликовать в канале Slack, у меня есть следующий скрипт в powershell
$header = @{
"Accept"="*/*"
"token"="f6b8a3cf-d78e-471d"
"Content-Type"="multipart/form-data"
}
function uploadScreenshots {
$path = "D:\Demo\PNG\Test.png"
$url = "https://slack.com/api/files.upload"
$Form = @{
channels = "poc_test"
file = $path
}
$response = Invoke-WebRequest -uri $url -Header $header -Method POST -Body $Form
write-host $response
}
uploadScreenshots
Когда я использую почтальон, он может успешно загрузить изображение, но вышескрипт дает мне "invalid_form_data"
{"ok":false,"error":"invalid_form_data"}
Почтальон Подробности:
curl --request POST \
--url https://slack.com/api/files.upload \
--header 'Accept: */*' \
--header 'Accept-Encoding: gzip, deflate' \
--header 'Cache-Control: no-cache' \
--header 'Connection: keep-alive' \
--header 'Content-Length: 122013' \
--header 'Content-Type: multipart/form-data; boundary=--------------------------125774860738041511758992' \
--header 'Host: slack.com' \
--header 'Postman-Token: 8add1159-ceb77250d51f' \
--header 'User-Agent: PostmanRuntime/7.17.1' \
--header 'cache-control: no-cache' \
--header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
--form file=@/D:/Demo/PNG/Test.png \
--form 'channels=poc_test' \
--form token=f6b8a3cf-d78e-471d