Issue Type
TODO:
Place an x in one of the [ ].
Description
(using the sdk in kotlin, pardon any confusing syntax differences)
nonempty .blocks added to an attachment will not post to the slack api, responds 400 invalid_attachments. Might also be related to #184 and #187
I have been posting to our webhook with plain JSON, and this seems to work fine:
curl -X POST -H 'Content-type: application/json' --data '{ "attachments": [ { "color": "#00FF00", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "*I would expect this text to show*" } } ] } ] }' https://hooks.slack.com/services/MY/WEBHOOK
However when I try to use the sdk payload builder, it wont send at all (and I think this is being constructed right)
val payload = Payload.builder()
.attachments(asAttachments(
attachment { a -> a.color("#00FF00").blocks(asBlocks(
section { s -> s.text(markdownText("*I would expect this text to show*")) }
)) }
))
.build()
I can however send this payload (empty blocks):
val payload = Payload.builder()
.attachments(asAttachments(
attachment { a -> a.color("#00FF00").blocks(asBlocks()) }
))
.build()
and this payload will send too (separate blocks and attachments):
val payload = Payload.builder()
.blocks(asBlocks(
section { s -> s.text(markdownText("block text!")) }
))
.attachments(asAttachments(
attachment { a -> a.color("#00FF00").text("attachment text!) }
))
.build()
but to construct our message as intended, we cant seem to get payloads constructed with attachments with blocks to post at all at runtime.
The issue is reproducible in:
- Module Version: 1.0.2
- JDK Version: TODO: Run
java -version and pates the result here
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)
- OS Version etc: TODO: if the issue happens only with specific OS
The steps to reproduce are:
val slack = Slack.getInstance()
val payload = Payload.builder()
.attachments(asAttachments(
attachment { a -> a.color("#00FF00").blocks(asBlocks(
section { s -> s.text(markdownText("*I would expect this text to show*")) }
)) }
))
.build()
res = slack.send(webhook, payload)
if (res.code != 200) {
print("slack reported status ${res.code}: ${res.body}")
}
The expected result is:
Either the sdk tells me at compile time what I'm building is incorrect/wont send. Otherwise the api should respond success to the message I'm sending.
The actual result is:
400 invalid_attachments
Requirements (place an x in each of the [ ])
TODO:
Issue Type
TODO:
Place an
xin one of the[ ].Description
(using the sdk in kotlin, pardon any confusing syntax differences)
nonempty
.blocksadded to an attachment will not post to the slack api, responds400 invalid_attachments. Might also be related to #184 and #187I have been posting to our webhook with plain JSON, and this seems to work fine:
However when I try to use the sdk payload builder, it wont send at all (and I think this is being constructed right)
I can however send this payload (empty blocks):
and this payload will send too (separate blocks and attachments):
but to construct our message as intended, we cant seem to get payloads constructed with attachments with blocks to post at all at runtime.
The issue is reproducible in:
java -versionand pates the result hereThe steps to reproduce are:
The expected result is:
The actual result is:
Requirements (place an
xin each of the[ ])TODO: