Question: I'm trying to pass a json script to curl using powershell. It seems to work if I hard code it right into a variable escaping the double quotes with backslash, but I want to pass the json in a file. I tried putting the json script in a separate json file and then use get-content and throw it in a variable, but it does not seem to work I get a "Validation\_Error". Any suggestions

This Works

[![enter image description here](https://i.stack.imgur.com/JEHdc.png)](https://i.stack.imgur.com/JEHdc.png)

But I want to do something like this

$json = Get-Content C:\test.json

curl -v -X POST <https://api.paypal.com/v1/invoicing/invoices/> \ -H "Content-Type:application/json" \ -H "Authorization: Bearer $token" \ -d $json

Answer: 
Try:

```
$json = Get-Content C:\test.json -Raw

```

By default `Get-Content` loads into an array of strings. The `-Raw` flag forces it to load into a single string.

You should also be able to do this and tell curl to read the file itself:

```
curl -v -X POST https://[...] -d @test.json

```

From the man page:

> 
> If you start the data with the letter @, the rest should be a file name to read the data from[.]
> 
> 
>
Remember curl in PoSH, is really this...

```
Get-Alias -Name curl

CommandType Name
----------- ----
Alias       curl -> Invoke-WebRequest 

```

... if you were not aware. The is another alias for Invoke-WebRequest as well.

If you want to use true curl in your PoSH session, you must use the full UNC to the executable (curl.exe) and that .exe extension is required or PoSH will use the alias above.

```
Get-Help -Name Invoke-WebRequest -Examples
Get-Help -Name Invoke-WebRequest -Full

```

So, for Invoke-WebRequest, the JSON must be in the body. Something like...

```
Invoke-WebRequest -uri "blahblahwhatever.com/api/uri" -Method POST -Body $JSON

```

So, virtually all the cmdlets have aliases, thus when we use commands we know that are really aliases, we must keep in mind what the real underlying cmdlet can and cannot do.