I was using:
curl -v -F file=@/tmp/x.png -F "initial_comment" -F channels='xyz' -H "Authorization: Bearer oauth" https://slack.com/api/files.upload
Works still very well, but file.upload
will be discontinued soon.
Now, after reading the doc, I tried:
curl
-H "Authorization: Bearer xxx"
-H "Content-Type: application/json"
-F "filename=/tmp/img.png"
-F "length=$(wc -c < /tmp/img.png)"
https://slack.com/api/files.getUploadURLExternal | jq .
or
curl -X POST
-H "Authorization: Bearer xxx"
-H "Content-Type: application/x-www-form-urlencoded"
-F "filename=@/tmp/img.png"
-F "length=$(wc -c < /tmp/img.png)"
https://slack.com/api/files.getUploadURLExternal | json .
But I get JSON error for the first one:
{
"ok": false,
"error": "invalid_arguments",
"warning": "missing_charset",
"response_metadata": {
"messages": [
"[ERROR] missing required field: length",
"[ERROR] missing required field: filename"
],
"warnings": [
"missing_charset"
]
}
}
and the second command:
{
"ok": false,
"error": "invalid_arg_name"
}
How to pass parameters correctly ? The doc have no example in Curl. My charset is utf8
, same, how to pass it?