Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending text file attachment using JSON #208

Open
ilium007 opened this issue Sep 8, 2024 · 2 comments
Open

Sending text file attachment using JSON #208

ilium007 opened this issue Sep 8, 2024 · 2 comments
Labels
question Further information is requested

Comments

@ilium007
Copy link

ilium007 commented Sep 8, 2024

Question
Is sending attachments using JSON supported? I want to send a text file (log file) using the JSON POST method. I have tried base64 encoding the file but can't get it to work.

@ilium007 ilium007 added the question Further information is requested label Sep 8, 2024
@ilium007
Copy link
Author

ilium007 commented Sep 8, 2024

I can send attachments using curl POST URL string in a shell scrip as a testt:

send_alert () {
  /usr/bin/curl -X POST \
    -F "title=$1" \
    -F "body=$2" \
    -F "attach=@$LOG_FILE" \
    $APPRISE_URL
}

Can this be done by sending a JSON string instead?

@caronc
Copy link
Owner

caronc commented Dec 20, 2024

Using curl it might be a bit tricky, but the payload needs to look like:

{
 "title": "Title",
 "body": "Body",
 "type": "info",
 "format": "text",
  "attachments": [
   {
     "filename": "filename.txt",
     "base64": "<base64>"
     "mimetype": "plain/text"
   }
  ]
}

If you have more than one attachment, you can chain them. But the easiest way is to just send the files along with the payload. Especially if you're using curl

# Send a notification with an attachment:
curl -X POST \
    -F 'urls=mailto://user:[email protected]' \
    -F 'body=test message' \
    -F [email protected] \
    http://localhost:8000/notify

# Send multiple attachments; just make sure the attach keyword is unique:
curl -X POST \
    -F 'urls=mailto://user:[email protected]' \
    -F 'body=test message' \
    -F [email protected] \
    -F attach2=@/my/path/to/Apprise.doc \
    http://localhost:8000/notify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants