When using Invoke-RestMethod to make multiple calls to PUT or DELETE objects on Box's API, the following error is returned:
Invoke-RestMethod : The operation has timed out
The issue is readily reproducible after 2 or 3 commands, whereas all other methods proceed without issue.
Environment
Custom Applications making calls to Box's API with Powershell's Invoke-RestMethod cmdlet.
Steps To Resolve
There is no direct solution, however there are a few workarounds available:
- Close TCP connections manually (Microsoft Guide).
- Use the Invoke-WebRequest cmdlet.
- If processing large batches of items (e.g. for user management scripts), run your jobs more frequently so that each individual job is small.
Root Cause
Please refer to this article on described on Microsoft TechNet.
Note: Powershell cmdlets and any Powershell SDKs are not developed or supported by Box. This article is purely for informational purposes. A full list of supported SDKs are available here.