Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Add retries into assigning folder permissions #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions ForgeBimApi/ForgeBimApiWrappers/BimProjectFoldersApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,29 @@ public bool AssignPermission(string projectId, string folderId, List<FolderPerm
request.AddHeader("Content-Type", "application/json");
request.AddHeader("x-user-id", userId);

IRestResponse response = ExecuteRequest(request);
int retriesRemaining = 5;
while (retriesRemaining > 0)
{
retriesRemaining--;
IRestResponse response = ExecuteRequest(request);

if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
return true;
}
else if(retriesRemaining > 0)
{
Log.Warn($"Failed to assgn role permissions to folder: {folderId}. Retry {retriesRemaining} more times...");

Thread.Sleep(15000);
}
else
{
return false;
}
}

return response.StatusCode == System.Net.HttpStatusCode.OK;
return false;
}


Expand Down