0

I have the following unit file:

[Unit]
Description=Sends a message to a discord channel

[Service]
Type=oneshot
ExecStart=curl --header "Content-Type: application/json" --request POST --data '{"content":"MESSAGE TEXT HERE"}' https://discord.com/api/webhooks/WEBHOOK_ID_HERE/WEBHOOK_TOKEN_HERE
DynamicUser=yes

# No [Install] since this is meant to be used with a timer

Running the curl command that is in ExecStart manually posts the message to the Discord channel that corresponds to this webhook, while starting the service produces the response {"code": 50109, "message": "The request body contains invalid JSON."} from the Discord server.

Is there any notable difference between running a command through systemd and directly? For example, I could not find any indication that there might be a maximum command length for ExecStart.

New contributor
L12C is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1

1 Answer 1

1

Solved. Thanks to A.B's comment I realized I had \ns in the message, and as it turns out systemd interprets them before executing the command. Escaping the slashes (\\n) solved this and now it works.

New contributor
L12C is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

L12C is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.