I am pretty new to Bash, so forgive my stupid questions.
The goal is to query an API in Bash, currently i am doing so with PS.
I am trying to convert my Powershell script to Bash, but not getting anywhere. Example in PS to GET the specific Model_id from a specific asset ($x).
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
$API_Key = Get-Content -Path $ScriptDir\API-key.ps1
$bearer_token = "$API_Key"
$header = @{"Authorization" ="Bearer "+$bearer_token}
$url_GET = "https://test-inventory/api/v1/hardware/bytag/$x"
$Asset = Invoke-RestMethod -Method Get -Uri $url_GET -Headers $header
$Model_id = $Asset.Model_id
Same for making a new asset trough POST
$url_POST = 'https://test-inventory/api/v1/hardware'
$Body = @{ "asset_tag" = "123"; "Another_example" = "dunno"}
Invoke-RestMethod -Method POST -Uri $url_POST -Headers $header -Body $Body
It is pretty simpel code in PS, but for some reason i can't get my head around it in Bash.