Friday, January 26, 2024

[SOLVED] curl --data-binary in PowerShell

Issue

If I have a curl command such as:

curl <url> \
  -H 'Content-Type: application/json' \
  -H 'API-Key: <key>' \
  --data-binary '{"blah":"blah {\n  blah2(accountId: id, integrations: {int1: {Vms: [{Id: id2, resourceGroups: [\"test1\", \"test2\", \"test3\"]}]}}) {\n    integrations {\n      id\n      name\n      service {\n        id\n        slug\n      }\n    }\n  }\n}\n", "variables":""}'

What would be the equivalent to --data-binary within Powershell? Some answer stated just running curl.exe, others mentioned to change the content-type. This does work as a shell script fine though. Just wondering if its possible to convert it to use Invoke-WebRequest within Powershell.


Solution

-Body parameter works with the payload



Answered By - nobrac
Answer Checked By - Pedro (WPSolving Volunteer)