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

can http report send supports POST with message in the body? #5170

Closed
2 tasks done
smetis opened this issue May 3, 2024 · 3 comments
Closed
2 tasks done

can http report send supports POST with message in the body? #5170

smetis opened this issue May 3, 2024 · 3 comments

Comments

@smetis
Copy link

smetis commented May 3, 2024

  • I have searched open and closed issues for duplicates.
  • I have searched the forum for related topics.

Environment info

  • Duplicati version: Duplicati - 2.0.7.1_beta_2023-05-25
  • Operating system: Windows Server
  • Backend: local

Description

Wanted to setup http send report. The url is http(s) URL and using POST method. The message needs to be send in POST body. The sent http function was triggered but return warning that there is illegal path character. It seems like the message is sent thru URL parameter instead of post body. I cannot find option to set the message into POST body. Not sure if this is supported.

Steps to reproduce

  1. Set "send-http-url" to "https://api.domain.com/network"
  2. Set "send-http-message" to "{"DisplayName":"Duplicati Backup Monitor", "Subject":"Duplicati %OPERATIONNAME% report for %backup-name%","Body":"%backup-name%"}"
  3. Trigger backup and wait for completion
  4. Backup successful but return warning on illegal path detected error.
  • Actual result:
    Backup successful but return warning on illegal path detected error
  • Expected result:
    Backup successful and https post request sent with the message in post body

Debug log

Failed to send message: System.ArgumentException: 路径中具有非法字符。
{"ClassName":"System.ArgumentException","Message":"路径中具有非法字符。","Data":null,"InnerException":null,"HelpURL":null,"StackTraceString":"   在 System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)\r\n   在 System.IO.Path.IsPathRooted(String path)\r\n   在 Duplicati.Library.Modules.Builtin.ReportHelper.OnFinish(Object result)","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":"8\nCheckInvalidPathChars\nmscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.IO.Path\nVoid CheckInvalidPathChars(System.String, Boolean)","HResult":-2147024809,"Source":"mscorlib","WatsonBuckets":null,"ParamName":null}

Due to the system was setup by Asia region IT support, the error is in chinese characters. The translation of it using google translate is "Illegal characters in path"

@kenkendk
Copy link
Member

kenkendk commented May 7, 2024

The message is sent with POST.

The --send-http-message parameter is a bit confusing, but is used to specify what fields are included in the message.
The implementation of a custom message is broken in this case, because it checks if the message is a filename here, and the template-like string you supply is not a valid path. This should be fixed.

You can place the text in a file, and then set --send-http-message=path-to-file.

But it looks like you want to send JSON data, so perhaps it is easier to remove the --send-http-message parameter and set --send-http-format=json ? This also correctly handles cases where the text contains characters that needs JSON escaping.

@kenkendk
Copy link
Member

Fixed with #5180

@duplicatibot
Copy link

This issue has been mentioned on Duplicati. There might be relevant details there:

https://forum.duplicati.com/t/pb-with-send-http-module-solved/17945/2

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

No branches or pull requests

3 participants