locked
Powershell invoke rest API meet "401-unauthorized: access is denied due to invalid credentials" error RRS feed

  • Question

  • User-1893705268 posted

    Hello everyone and thanks for your help in advance.

    I try to use windows Powershell invoke the kudu rest api, but is show me this error:

     

    the user name and password are come from the publish setting file

    I also try to re-set the publish setting file, but not success.

    Thursday, October 26, 2017 2:05 AM

Answers

  • User-271186128 posted

    Hi D.Eason,

    Welcome to asp.net forum.

     401-unauthorized: access is denied due to invalid credentials

    According to your Power shell script, I suppose the issue is related to the username.

    Since the deployment username contains a '$' in the beginning, then PowerShell will treats it as a local variable instead of a literal string. 

    To escape the username, we need to add a '`(backtick)' in front of the $ sign. Like this:

    $username = "`$websitename"

    Best regards,
    Dillion

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 26, 2017 7:27 AM

All replies

  • User-271186128 posted

    Hi D.Eason,

    Welcome to asp.net forum.

     401-unauthorized: access is denied due to invalid credentials

    According to your Power shell script, I suppose the issue is related to the username.

    Since the deployment username contains a '$' in the beginning, then PowerShell will treats it as a local variable instead of a literal string. 

    To escape the username, we need to add a '`(backtick)' in front of the $ sign. Like this:

    $username = "`$websitename"

    Best regards,
    Dillion

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 26, 2017 7:27 AM
  • User-1893705268 posted

    Thanks, it works.

    Sunday, October 29, 2017 3:59 PM