none
Invoke-WebRequest authentication using token RRS feed

  • Question

  • Hello, 

    I have a command which is working fine in unix shell script which I used to connect to sonarqube and create a project 

    curl -u ca37e06bbbe5123126fe790f14a22206d5f8368c8664: -X POST "http://sonarqube.it.test.net:9000/api/projects/create?key=%project_key%&name=%project_name%" > NUL

    I have to write the same using Invoke-WebRequest using powershell. I tried below , but getting error

    $e = @{
        Uri     = "http://sonarqube.it.test.net:9000/api/projects/create?key=%project_key%&name=%project_name%"
        Headers = @{"Authorization" = "Token ca37e06bbbe5123126fe790f14a22206d5f8368c8664"}
    }
    Invoke-WebRequest @e -Method POST


    but i'm getting error message : 

    Invoke-WebRequest : The remote server returned an error: (401) Unauthorized.

    • Edited by LeoJM Monday, September 17, 2018 1:42 PM spell correct
    • Moved by Bill_Stewart Wednesday, December 12, 2018 10:24 PM This is not "develop custom solutions for me" forum
    Monday, September 17, 2018 1:41 PM