none
Table storage: {"Element 1 in the batch returned an unexpected response code."}

    Question

  • Can't find anything on this error? {"Element 1 in the batch returned an unexpected response code."}

    Here is the code..

    foreach (var batch in matchingAds.Batch(100))
                {
                    TableBatchOperation batchOperation = new TableBatchOperation();
                    foreach (var ad in batch)
                    {
                        var notificationEntity = new AdNotificationEntity(DateTime.Today.ToShortDateString(), DateTime.UtcNow.Ticks.ToString());
                        notificationEntity.Email = ad.Owner;
                        batchOperation.Insert(notificationEntity);
                    }
                    try
                    {
                        await _newTradesTable.ExecuteBatchAsync(batchOperation);
                    }
                    catch (InvalidOperationException ie)
                    {
                        // Set up some properties:
                        var properties = new Dictionary<string, string>
                        { {"AdService", "AddNewAdNotifications exceptionmessage: "+ie.Message}};
    
                        // Send the exception telemetry:
                        _telemetry.TrackException(ie, properties);
                    }
                    catch (Exception e)
                    {
                        // Set up some properties:
                            var properties = new Dictionary<string, string>
                        { {"AdService", "AddNewAdNotifications exceptionmessage: "+e.Message}};
    
                        // Send the exception telemetry:
                        _telemetry.TrackException(e, properties);
                    }
                }

    My batch looks like this:

    public static IEnumerable<IEnumerable<T>> Batch<T>(this IEnumerable<T> items, maxItems)
            {
                return items.Select((item, inx) => new { item, inx })
                            .GroupBy(x => x.inx / maxItems)
                            .Select(g => g.Select(x => x.item));
            }
    
    I just added the batch functionality since I got errors with the 99th element of the batch..

    Thursday, April 14, 2016 8:16 PM

Answers

  • I think I figured it to be a duplicate key for the ticks part of the code. Replaced it with the following code and now it works.

    var notificationEntity = new AdNotificationEntity(DateTime.Today.ToShortDateString(), Guid.NewGuid().ToString());
    

    Tuesday, April 26, 2016 6:43 PM

All replies

  • Hi,

    Sincere apologies for the delay in responding.

    We are checking on this and will revert to you at the earliest.

    Girish Prajwal

    Tuesday, April 26, 2016 6:39 PM
    Moderator
  • I think I figured it to be a duplicate key for the ticks part of the code. Replaced it with the following code and now it works.

    var notificationEntity = new AdNotificationEntity(DateTime.Today.ToShortDateString(), Guid.NewGuid().ToString());
    

    Tuesday, April 26, 2016 6:43 PM