PowerShell Credentials being invalidated for REST API Requests
I have a whole lot of requests that need to be made, hundreds infact. I run a simple for
loop which then runs a new request for each object in an array.
The odd thing is that initially, these requests all succeed. However, once we get to the later hundreds, like 500 or so it then breaks and throws the following error constantly for each request
Invoke-WebRequest : Access Denied Your credentials could not be authenticated: "Credentials are missing.". You will not be permitted access until your credentials can be verified.
I found a few references to this issue being somethign that crops up regularly with regards to proxies in powershell but honestly can't make sense of their solutions.
Relevant Links:
- Fix for .NET apps
- Proxy defaults in .NET
Can anyone help me make sense of this? Here is my code in full for better clarification
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$user = '*********'
$base = "https://*********.com/api/xm/1/groups"
$pass = ConvertTo-SecureString '*********' -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user, $pass
$req = Invoke-WebRequest -Credential $cred -Uri https://*********.com/api/xm/1/groups?limit=999
$res = ConvertFrom-Json $req.Content
$content = $res.data
for($x = 0; $x -lt $content.length; $x++)
$group_name = $content[$x].targetName
$del_path = "$base/$group_name/shifts/MAX"
$del_path_2 = "$base/$group_name/shifts/MAX-Default Shift"
Invoke-RestMethod -Credential $cred -Uri $del_path -Method DELETE
Invoke-RestMethod -Credential $cred -Uri $del_path_2 -Method DELETE
if ($x -eq 200 -or $x -eq 350 -or $x -eq 500)
Start-Sleep -s 30
.net powershell proxy credentials proxies
add a comment |
I have a whole lot of requests that need to be made, hundreds infact. I run a simple for
loop which then runs a new request for each object in an array.
The odd thing is that initially, these requests all succeed. However, once we get to the later hundreds, like 500 or so it then breaks and throws the following error constantly for each request
Invoke-WebRequest : Access Denied Your credentials could not be authenticated: "Credentials are missing.". You will not be permitted access until your credentials can be verified.
I found a few references to this issue being somethign that crops up regularly with regards to proxies in powershell but honestly can't make sense of their solutions.
Relevant Links:
- Fix for .NET apps
- Proxy defaults in .NET
Can anyone help me make sense of this? Here is my code in full for better clarification
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$user = '*********'
$base = "https://*********.com/api/xm/1/groups"
$pass = ConvertTo-SecureString '*********' -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user, $pass
$req = Invoke-WebRequest -Credential $cred -Uri https://*********.com/api/xm/1/groups?limit=999
$res = ConvertFrom-Json $req.Content
$content = $res.data
for($x = 0; $x -lt $content.length; $x++)
$group_name = $content[$x].targetName
$del_path = "$base/$group_name/shifts/MAX"
$del_path_2 = "$base/$group_name/shifts/MAX-Default Shift"
Invoke-RestMethod -Credential $cred -Uri $del_path -Method DELETE
Invoke-RestMethod -Credential $cred -Uri $del_path_2 -Method DELETE
if ($x -eq 200 -or $x -eq 350 -or $x -eq 500)
Start-Sleep -s 30
.net powershell proxy credentials proxies
1
Does the documentation for this talk about rate limiting? I wonder if this is happening because of the request frequency. Although I would expect the error to be different.
– Matt
Nov 14 '18 at 18:55
Nope. Just checked in their docs. This would throw a 429 if that was the case, which it's not. This is something local to my machine running the script.
– M_A87
Nov 14 '18 at 18:58
add a comment |
I have a whole lot of requests that need to be made, hundreds infact. I run a simple for
loop which then runs a new request for each object in an array.
The odd thing is that initially, these requests all succeed. However, once we get to the later hundreds, like 500 or so it then breaks and throws the following error constantly for each request
Invoke-WebRequest : Access Denied Your credentials could not be authenticated: "Credentials are missing.". You will not be permitted access until your credentials can be verified.
I found a few references to this issue being somethign that crops up regularly with regards to proxies in powershell but honestly can't make sense of their solutions.
Relevant Links:
- Fix for .NET apps
- Proxy defaults in .NET
Can anyone help me make sense of this? Here is my code in full for better clarification
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$user = '*********'
$base = "https://*********.com/api/xm/1/groups"
$pass = ConvertTo-SecureString '*********' -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user, $pass
$req = Invoke-WebRequest -Credential $cred -Uri https://*********.com/api/xm/1/groups?limit=999
$res = ConvertFrom-Json $req.Content
$content = $res.data
for($x = 0; $x -lt $content.length; $x++)
$group_name = $content[$x].targetName
$del_path = "$base/$group_name/shifts/MAX"
$del_path_2 = "$base/$group_name/shifts/MAX-Default Shift"
Invoke-RestMethod -Credential $cred -Uri $del_path -Method DELETE
Invoke-RestMethod -Credential $cred -Uri $del_path_2 -Method DELETE
if ($x -eq 200 -or $x -eq 350 -or $x -eq 500)
Start-Sleep -s 30
.net powershell proxy credentials proxies
I have a whole lot of requests that need to be made, hundreds infact. I run a simple for
loop which then runs a new request for each object in an array.
The odd thing is that initially, these requests all succeed. However, once we get to the later hundreds, like 500 or so it then breaks and throws the following error constantly for each request
Invoke-WebRequest : Access Denied Your credentials could not be authenticated: "Credentials are missing.". You will not be permitted access until your credentials can be verified.
I found a few references to this issue being somethign that crops up regularly with regards to proxies in powershell but honestly can't make sense of their solutions.
Relevant Links:
- Fix for .NET apps
- Proxy defaults in .NET
Can anyone help me make sense of this? Here is my code in full for better clarification
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$user = '*********'
$base = "https://*********.com/api/xm/1/groups"
$pass = ConvertTo-SecureString '*********' -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user, $pass
$req = Invoke-WebRequest -Credential $cred -Uri https://*********.com/api/xm/1/groups?limit=999
$res = ConvertFrom-Json $req.Content
$content = $res.data
for($x = 0; $x -lt $content.length; $x++)
$group_name = $content[$x].targetName
$del_path = "$base/$group_name/shifts/MAX"
$del_path_2 = "$base/$group_name/shifts/MAX-Default Shift"
Invoke-RestMethod -Credential $cred -Uri $del_path -Method DELETE
Invoke-RestMethod -Credential $cred -Uri $del_path_2 -Method DELETE
if ($x -eq 200 -or $x -eq 350 -or $x -eq 500)
Start-Sleep -s 30
.net powershell proxy credentials proxies
.net powershell proxy credentials proxies
asked Nov 14 '18 at 18:47
M_A87M_A87
76
76
1
Does the documentation for this talk about rate limiting? I wonder if this is happening because of the request frequency. Although I would expect the error to be different.
– Matt
Nov 14 '18 at 18:55
Nope. Just checked in their docs. This would throw a 429 if that was the case, which it's not. This is something local to my machine running the script.
– M_A87
Nov 14 '18 at 18:58
add a comment |
1
Does the documentation for this talk about rate limiting? I wonder if this is happening because of the request frequency. Although I would expect the error to be different.
– Matt
Nov 14 '18 at 18:55
Nope. Just checked in their docs. This would throw a 429 if that was the case, which it's not. This is something local to my machine running the script.
– M_A87
Nov 14 '18 at 18:58
1
1
Does the documentation for this talk about rate limiting? I wonder if this is happening because of the request frequency. Although I would expect the error to be different.
– Matt
Nov 14 '18 at 18:55
Does the documentation for this talk about rate limiting? I wonder if this is happening because of the request frequency. Although I would expect the error to be different.
– Matt
Nov 14 '18 at 18:55
Nope. Just checked in their docs. This would throw a 429 if that was the case, which it's not. This is something local to my machine running the script.
– M_A87
Nov 14 '18 at 18:58
Nope. Just checked in their docs. This would throw a 429 if that was the case, which it's not. This is something local to my machine running the script.
– M_A87
Nov 14 '18 at 18:58
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53306892%2fpowershell-credentials-being-invalidated-for-rest-api-requests%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53306892%2fpowershell-credentials-being-invalidated-for-rest-api-requests%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Does the documentation for this talk about rate limiting? I wonder if this is happening because of the request frequency. Although I would expect the error to be different.
– Matt
Nov 14 '18 at 18:55
Nope. Just checked in their docs. This would throw a 429 if that was the case, which it's not. This is something local to my machine running the script.
– M_A87
Nov 14 '18 at 18:58