Precondition Failed 412 Error when Updating a Report
See original GitHub issueStarting last Saturday (April 28th) we get an exception when we try to update report dates using the DCM Reporting API. The error doesn’t happen all the time but it happens quite a lot on our process since it updates a lot of reports every day. It is really unclear why we started to get this error suddenly without changing anything in our process.
I hope you could help us understand how to solve the problem. Please find below the exception we get and the method which performs the update in C# code.
Please let me know if you need any further information in order to figure it out.
The exception:
Google.Apis.Requests.RequestError
Precondition Failed [412]
Errors [
Message[Precondition Failed] Location[If-Match - header] Reason[conditionNotMet] Domain[global]
]
at Google.Apis.Requests.ClientServiceRequest1.<ParseResponse>d__34.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Google.Apis.Requests.ClientServiceRequest
1.Execute()
at ExtractDataFromDCM.DfaReporter.UpdateReportDates(Int64 profileId, Int64 reportId, DateTime startDate, DateTime endDate) in C:\Sources\ExtractDataFromDCM\3p\ExtractDataFromDCM\DfaReporter.cs:line 160
The method which updates the report dates (C# code):
public Report UpdateReportDates(long profileId, long reportId, DateTime startDate, DateTime endDate)
{
try
{
//Gets the report from DoubleClick.
var report = GetReport(profileId);
//Create the report if it doesn't exist.
if (report == null)
{
return CreateReport(profileId, startDate, endDate);
}
//Change dates format as DoubleClick expects it.
var dateRange = new DateRange
{
EndDate = endDate.ToString("yyyy-MM-dd"),
StartDate = startDate.ToString("yyyy-MM-dd")
};
//Updates the dates in the report object.
report.Criteria.DateRange = dateRange;
//Updates the report object in DoubleClick.
return _service.Reports.Update(report, profileId, reportId).Execute();
}
catch (Exception ex)
{
throw new Exception($"Failed to update report #{reportId} for profile #{profileId} in DoubleClick", ex);
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:26
Top GitHub Comments
The error is stating that the
etag
header does not match on the update request. This probably means that the report has already been updated between where the code callsGetReport()
, before_service.Reports.Update(...)
. Is it possible that the code is updating the same report multiple times concurrently? This would trigger this situation.@cfrederickson-kpbsd: Given that this is about a different API, I suspect it’s a different cause, and it would be best to open a new issue. Please include more details of what you mean by “For further information, the ETags are different.”