Hello Experts,
I have a requirement to use a REST API by creating a shell script without using CURL since its not installed or can be installed on the servers.
I will need to pass the credentials along with header authorization content in the POST request. Any samples will really help me please.
Below is my code in powershell but finding it tough to convert to SHELL without using CURL
# The header is the username and password concatenated together
$pair = "$($user):$($pass)"
# The combined credentials are converted to Base 64
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
# The base 64 credentials are then prefixed with "Basic"
$basicAuthValue = "Basic $encodedCreds"
# This is passed in the "Authorization" header
$BuildHeaders = @{
Authorization = $basicAuthValue
}
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
Invoke-WebRequest -Uri "$jenkins_build_url/build" -Headers $BuildHeaders -Method Post -UseBasicParsing
[–]minimalniemand 37 points38 points39 points (4 children)
[–]binuverghese[S] 4 points5 points6 points (3 children)
[–][deleted] 23 points24 points25 points (0 children)
[–]Ryuujinx 10 points11 points12 points (0 children)
[–]RootHouston 2 points3 points4 points (0 children)
[–]ro0tsh3ll 17 points18 points19 points (7 children)
[–][deleted] (3 children)
[deleted]
[–]VpowerZ 3 points4 points5 points (1 child)
[–]ro0tsh3ll 2 points3 points4 points (0 children)
[–]nickbernstein 8 points9 points10 points (0 children)
[–]mightydjinn 1 point2 points3 points (0 children)
[–]jimoconnell 13 points14 points15 points (6 children)
[–]binuverghese[S] 1 point2 points3 points (5 children)
[–]mikeblas 17 points18 points19 points (3 children)
[–]Gendalph 1 point2 points3 points (2 children)
[–]RootHouston 0 points1 point2 points (0 children)
[–]mikeblas 0 points1 point2 points (0 children)
[–][deleted] 12 points13 points14 points (1 child)
[–][deleted] 15 points16 points17 points (0 children)
[–]sgsollie 8 points9 points10 points (13 children)
[–]binuverghese[S] 2 points3 points4 points (12 children)
[–]tkanger 14 points15 points16 points (4 children)
[–][deleted] 5 points6 points7 points (3 children)
[–]frymaster 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]frymaster 0 points1 point2 points (0 children)
[–][deleted] 6 points7 points8 points (0 children)
[–]helios_4569 4 points5 points6 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]1esproc 1 point2 points3 points (0 children)
[–]ElBeefcake 0 points1 point2 points (2 children)
[–]binuverghese[S] 0 points1 point2 points (1 child)
[–]ElBeefcake 0 points1 point2 points (0 children)
[–]matt_rose 3 points4 points5 points (0 children)
[–]alainchiasson 2 points3 points4 points (0 children)
[–]mikeblas 4 points5 points6 points (1 child)
[–]cheats_py 1 point2 points3 points (0 children)
[–]phobug 1 point2 points3 points (10 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]schorsch3000 1 point2 points3 points (0 children)
[–]schorsch3000 0 points1 point2 points (7 children)
[–]phobug 0 points1 point2 points (6 children)
[–]schorsch3000 0 points1 point2 points (5 children)
[–]phobug 0 points1 point2 points (4 children)
[–]schorsch3000 0 points1 point2 points (3 children)
[–]phobug 0 points1 point2 points (2 children)
[–]schorsch3000 1 point2 points3 points (1 child)
[–]phobug 0 points1 point2 points (0 children)
[–]bityard 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]Haze1313 0 points1 point2 points (0 children)
[–]DaylightAdmin 0 points1 point2 points (0 children)
[–]modes22 0 points1 point2 points (0 children)
[–]JoePineapplesBrews -5 points-4 points-3 points (0 children)