-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoker.ps1
33 lines (27 loc) · 912 Bytes
/
invoker.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Set the API key
$apiKey = 'YOUR_API_KEY' #between simple quotes
<#
Example, if you would provide the data directly in the script
$jsonContent = '{"sample": "Hello Worlde"}'
#>
# Read the content from the "data.json" file
$jsonContent = Get-Content -Path "data.json" -Raw
# Set the URL for the JSONBin update API
$url = "https://api.jsonbin.io/v3/b/<YOUR_BIN_ID>"
# Build the headers as a hashtable
$headers = @{
"Content-Type" = "application/json"
"X-Access-Key" = $apiKey
}
try {
# Invoke the API using Invoke-RestMethod
$response = Invoke-RestMethod -Uri $url -Method PUT -Headers $headers -Body $jsonContent
# Check if the request was successful
if ($response) {
Write-Host "Successfully updated the JSONBin content."
} else {
Write-Host "Error updating JSONBin."
}
} catch {
Write-Host "Error updating JSONBin: $_"
}