I'm trying to send a HTML request via cURL in PowerShell. The code in question:
$command = 'curl -d @request.txt -o testoutput.xml -X "POST" -H @header.txt -u "username:password" "URL"'
Invoke-Expression $command
The HTML Body (-d) and Header (-H) need to be read from files, hence the @ before the filenames.
In order for this to work, I need to escape the @ so PowerShell doesn't interpret it as a splat operator - and that's my problem, nothing I've tried so far worked:
- putting it in single quotes
- here document (@" "@)
- here string (@' '@)
- using string templates with placeholders ("{0}request.txt" -f "@")
- Unicode escape ("`u{0040}request.txt")
How do I escape the @ correctly? Or am I on the wrong path entirely? (I'm new to PowerShell sorry)