knadh / listmonk

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.
https://listmonk.app
GNU Affero General Public License v3.0
14.54k stars 1.33k forks source link

Correct parameters to pass API request to send campaign test email? #1972

Closed panomitrius closed 1 month ago

panomitrius commented 1 month ago

Version:

Description of the bug and steps to reproduce: I can't find a way to use API request to send campaign test email. I keep getting this error message:

{"message":"Invalid length for name."}

When using this bash script

#!/bin/bash

BASE_URL="https://link.to.listmonk"
USERNAME="listmonk"
PASSWORD="password"

CAMPAIGN_ID=16 

SUBSCRIBER_EMAILS=('test@test.com')

SUBSCRIBER_JSON=$(printf '%s' "${SUBSCRIBER_EMAILS[@]}" | jq -R -s -c 'split("\n")[:-1]')

curl -s -u "$USERNAME:$PASSWORD" -X POST "$BASE_URL/api/campaigns/$CAMPAIGN_ID/test" \
-H 'Content-Type: application/json;charset=utf-8' \
-d '{"subscribers": '"$SUBSCRIBER_JSON"'}' --verbose

The campaign I want to send has ID=16. What else do I need to pass to send the list?

knadh commented 1 month ago

Please refer to the docs: https://listmonk.app/docs/apis/campaigns/#post-apicampaignscampaign_idtest

Use the same parameters in POST /api/campaigns in addition to the below parameters.

You've to pass the same params you'd pass to campaign creation.