-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCoincap.ps1
37 lines (30 loc) · 906 Bytes
/
Coincap.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
34
35
36
37
param (
[string]$identifier = "coincap.io PS",
[string]$type = "Crypto Assets PS"
)
$header_params = @{
"identifier" = $identifier
"type" = $type
}
if ($args.Count -ge 2) {
$identifier = $args[0]
$type = $args[1]
$header_params = @{
"identifier" = $identifier
"type" = $type
}
}
Write-Host $header_params
# Make the GET request to coincap.io
$coincapResponse = Invoke-RestMethod -Uri "https://api.coincap.io/v2/assets" -Method Get
# Set additional headers
$headers = @{
"Content-Type" = "application/json"
"accept" = "application/json"
}
$headers += $header_params
$body = $coincapResponse | ConvertTo-Json
# Send the PUT request with the JSON response from the GET request
$uri = "http://localhost:34567/api/data/parameters"
$response = Invoke-RestMethod -Uri $uri -Method Put -Headers $headers -Body $body
echo $response | ConvertTo-Json