Sample Header Ad - 728x90

Curl produces different results when invoked via systemd vs command line

0 votes
1 answer
525 views
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.
Asked by L12C (11 rep)
Mar 18, 2023, 10:09 AM
Last activity: Mar 18, 2023, 02:15 PM