I amI am trying to using powershell scripting to access the API. I have tried a couple ways (example 1, 2 below) . Both result in same message "You are not authorized to access this resource!" I know that my User has admin rights to the goserver. API documentation has the following example A. Is anyone else using the API via powershell scripting ? What I am doing wrong?
Example A: $ curl 'https://ci.example.com/go/api/current_user' \ -u 'username:password' \ -H 'Accept: application/vnd.go.cd.v1+json' \ Example 1: $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add('Accept', 'application/vnd.go.cd.v1+json') $Body = @{ User = 'someuser' password = 'somepassword' } $response = Invoke-RestMethod -Uri "https://goserver:8154/go/api/current_user" -Headers $headers -Body $Body -Method post; Example 2: $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add('Accept', 'application/vnd.go.cd.v1+json') $secpasswd = ConvertTo-SecureString 'somepassword' -AsPlainText -Force $mycreds = New-Object System.Management.Automation.PSCredential ('someuser', $secpasswd) $response = Invoke-RestMethod -Uri "https://goserver:8154/go/api/current_user" -Headers $headers -Credential $mycreds -Method post; -- You received this message because you are subscribed to the Google Groups "go-cd" group. To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.