我在通过LinkedIn API发布创意时遇到了一些问题。这是一个纯粹针对LinkedIn工程师的问题,因为我确信这不是代码问题。问题似乎发生在大量张贴与相关创意的宣传活动中。使用Thread.Sleep / await Task.Delay方法和同步运行没有帮助。这个错误完全不是描述性的,但是我已经删除了错误的请求和代码错误的原因。这绝对是一个API问题。我想更深入地了解我可以给服务器打多少次电话,以及我能多长时间打一次电话,但这似乎也与此无关。我试着调试和等待10-20秒后,才发布一个创意。
我通过API所做的工作如下:
让我补充一句,我已经确定当我试图发布一个Creative时,它确实具有引用的共享ID和引用的活动ID。
错误信息:
{“消息”:“验证失败是因为{reason=FAIL_TO_RETRIEVE_UPDATE、field=reference、batchIndex=0、type=REMOTE_OPERATION_FAILED、message=Fail检索更新。可能是临时失败。引用,parameters={value=,key=}”,“状态”:400}
发布于 2019-09-25 15:16:59
在此期间,请看一下关于这个问题的以下工作:
我介绍了一些重试逻辑,并结合了await Task.Delay()方法,这似乎有点帮助,如果它与上述错误失败,4-5重试通常是足够继续进行。
public async Task<string> PostTheContentAsync(HttpClient httpClient, object campaignManagerObject, string reqUrl, int retriesRemaining = 5)
{
try
{
ByteArrayContent byteContent = CreateByteArrayContent(campaignManagerObject);
var response = await httpClient.PostAsync(reqUrl, byteContent);
response.EnsureSuccessStatusCode();
IEnumerable<string> headerValue = response.Headers.GetValues("X-LinkedIn-Id");
return headerValue.First();
}
catch
{
if (retriesRemaining > 0) //and exception is temporary
{
await Task.Delay(5000);
return await PostTheContentAsync(httpClient, campaignManagerObject, reqUrl, retriesRemaining - 1);
}
throw new Exception($"Error while posting the content of {campaignManagerObject.GetType()} for URL: {reqUrl} in {nameof(ManagementBaseClass)}, {nameof(PostTheContentAsync)}.");
}
}https://stackoverflow.com/questions/58065546
复制相似问题