Ask a Question

Ask a Question
Back to All

BeamContext.Api.AnnouncementService.GetCurrent() throws a PlatformRequesterException

Hello,

We're trying to create a simple newsfeed using the announcements feature.
Unfortunately somewhere along the way BeamContext.Api.AnnouncementService.GetCurrent started throwing an error:

PlatformRequesterException: HTTP Error. method=[GET] uri=[https://api.beamable.com/object/announcements/1638718414390273] code=[500] payload=[{"status":500,"service":"announcements","error":"InternalError","message":"(ImageUrl,null) (of class scala.Tuple2)"}]
Beamable.Api.PlatformRequester.HandleError[T] (System.Exception error, System.String contentType, System.Byte[] body, Beamable.Common.Api.SDKRequesterOptions`1[T] opts) (at Library/PackageCache/[email protected]/Runtime/Core/Platform/SDK/PlatformRequester.cs:437)
Rethrow as UncaughtPromiseException: Uncaught promise innerMsg=[HTTP Error. method=[GET] uri=[https://api.beamable.com/object/announcements/1638718414390273] code=[500] payload=[{"status":500,"service":"announcements","error":"InternalError","message":"(ImageUrl,null) (of class scala.Tuple2)"}]] innerType=[PlatformRequesterException]
UnityEngine.Debug:LogException(Exception)
Beamable.Common.BeamableLogUnityProvider:Error(Exception) (at Library/PackageCache/[email protected]/Common/Runtime/Debug.cs:66)
Beamable.Common.BeamableLogger:LogException(Exception) (at Library/PackageCache/[email protected]/Common/Runtime/Debug.cs:149)
Beamable.<<PromiseBaseOnPotentialOnPotentialUncaughtError>g__DelayedCheck|0>d:MoveNext() (at Library/PackageCache/[email protected]/Runtime/PromiseExtensions.cs:47)
UnityEngine.UnitySynchronizationContext:ExecuteTasks()

Below is the code we've been using:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Beamable;
using Beamable.Common.Api.Announcements;

namespace Newsfeed.Beamable
{
    public class BeamableAnnouncementService
    {
        public event Action<List<AnnouncementView>> OnNewAnnouncementsReceived;
        public IReadOnlyList<AnnouncementView> Announcements => _announcements.AsReadOnly();

        private readonly List<AnnouncementView> _announcements = new();
        
        private BeamContext _beamContext;
        private bool _initialized;

        public async Task Initialize()
        {
            if (_initialized)
                return;

            // initialise Beamable context
            _beamContext = BeamContext.Default;
            await _beamContext.OnReady;

            // fetch current announcements
            var response = await _beamContext.Api.AnnouncementService.GetCurrent();
            _announcements.AddRange(response.announcements.ToList());
            
            // subscribe to new announcements
            _beamContext.Api.AnnouncementService.Subscribe(queryResponse =>
            {
                _announcements.AddRange(queryResponse.announcements.ToList());
                OnNewAnnouncementsReceived?.Invoke(_announcements);
            });

            _initialized = true;
        }
    }
}

Our alias is gamedev-tube, there is only one game on our account and we're currently utilising only the prod realm.

Best
BB