This commit is contained in:
2021-08-24 17:36:55 +00:00
parent a9d9326db8
commit f89fada37b

View File

@@ -250,12 +250,57 @@ namespace AyaNova.PlugIn.V8
}
public async static Task<ApiResponse> PutAsync(string route, dynamic d)
{
return await PutAsync(route, d.ToString(Newtonsoft.Json.Formatting.None));
Exception FirstException = null;
for (int x = 0; x < MAX_TRIES; x++)
{
try
{
return await TryPutAsync(route, d.ToString(Newtonsoft.Json.Formatting.None));
}
catch (Exception ex)
{
if (FirstException == null)
FirstException = ex;
}
}
//no luck re-throw the exception
throw FirstException;
}
public async static Task<ApiResponse> PutAsync(string route, string putJson = null)
public async static Task<ApiResponse> PutAsync(string route)
{
Exception FirstException = null;
for (int x = 0; x < MAX_TRIES; x++)
{
try
{
return await TryPutAsync(route);
}
catch (Exception ex)
{
if (FirstException == null)
FirstException = ex;
}
}
//no luck re-throw the exception
throw FirstException;
}
public async static Task<ApiResponse> TryPutAsync(string route, string putJson = null)
{
var requestMessage = new HttpRequestMessage(HttpMethod.Put, ApiBaseUrl + route);
requestMessage.Headers.Add("X-AY-Import-Mode", "1");
@@ -289,7 +334,36 @@ namespace AyaNova.PlugIn.V8
}
public async static Task<ApiResponse> PostFormDataAsync(string route, MultipartFormDataContent formContent)
{
Exception FirstException = null;
for (int x = 0; x < MAX_TRIES; x++)
{
try
{
return await TryPostFormDataAsync(route, formContent);
}
catch (Exception ex)
{
if (FirstException == null)
FirstException = ex;
}
}
//no luck re-throw the exception
throw FirstException;
}
private async static Task<ApiResponse> TryPostFormDataAsync(string route, MultipartFormDataContent formContent)
{
var requestMessage = new HttpRequestMessage(HttpMethod.Post, ApiBaseUrl + route);
requestMessage.Headers.Add("X-AY-Import-Mode", "1");