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

Win11 batch file fails "curl" notification #674

Closed
truthsword opened this issue Jul 29, 2024 · 3 comments
Closed

Win11 batch file fails "curl" notification #674

truthsword opened this issue Jul 29, 2024 · 3 comments
Labels
question Further information is requested

Comments

@truthsword
Copy link

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!

@truthsword truthsword added the question Further information is requested label Jul 29, 2024
@BroderPeters
Copy link

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?

@eternal-flame-AD
Copy link
Member

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.

@truthsword
Copy link
Author

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"

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

No branches or pull requests

3 participants