gotify/server

Win11 batch file fails "curl" notification

truthsword opened this issue · 3 comments

I want to send a notification upon completion of a batch file running in Windows. I tacked on the following curl command to my batch file:

curl "http://192.168.1.60:8070/message?token=njvrfrihrfr" -F "title=some stuff here" -F "message=Backup Complete" -F "priority=5"

But it failed with this response:

Invoke-WebRequest : A parameter cannot be found that matches parameter name 'F'.
At line:1 char:65
+ ... "http://192.168.1.60:8070/message?token=njvrfrihrfr" -F "title= ...
+                                                                ~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

This curl command works fine in Debian. What's the trick with Win11? Thanks!

From what I can tell, Windows 11 or the batch file are converting your curl request to Invoke-WebRequest as a command.
Similar situation here. Can you ensure that this is not the case for you?

BroderPeters thanks for the great answer!

@truthsword To build on their answer, you could do either:

  • Install regular curl, the easiest way to do it is to go to cURL website and download a binary, then Remove-Alias curl; curl <...> or use path\to\curl.exe <...>
  • Use the built-in web request facility in PowerShell. It should look something like this: Invoke-WebRequest "http://192.168.1.60:8070/message?token=njvrfrihrfr" -Method POST -Form @{ title = "some stuff here"; message = "hello!" }

All semicolons can be replaced with a new line.

Thank you, @BroderPeters and @eternal-flame-AD. I located curl.exe natively in C:\Windows\System32, so I used that full path (I thought about adding curl to the PATH environmental variable), so this worked:

c:\Windows\System32\curl.exe "http://192.168.1.60:8070/message?token=njvrfrihrfr" -F "title=some stuff here" -F "message=Backup Complete" -F "priority=5"