I can’t resolve this error. It occurs when running a self hosted servicestack service.
If I initialize a request using
var service = appHost.Resolve<MovieService();
service.Request = new MockHttpRequest
{
XRealIp = "192.168.1.10",
IsLocal = true,
Headers = RequestHeaders,
Authorization = ApiKey
};
var response = service.Gateway.Send(new SomeRequest{Id = 1});
and then within that method call other services using subsequent Gateway.Send I get an error like the following.
[GetDbMovie: 4/30/2020 11:37:11 PM]:
[REQUEST: {id:220725}]
System.ArgumentNullException: Value cannot be null. (Parameter ‘key’)
at System.Collections.Generic.Dictionary2.FindEntry(TKey key) at System.Collections.Generic.Dictionary
2.TryGetValue(TKey key, TValue& value)
at ServiceStack.ApplyToUtils.HttpMethodAsApplyTo(IRequest req) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\ApplyTo.cs:line 57
at ServiceStack.RequestFilterAsyncAttribute.RequestFilterAsync(IRequest req, IResponse res, Object requestDto) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\RequestFilterAttribute.cs:line 65
at ServiceStack.Host.ServiceRunner`1.ExecuteAsync(IRequest req, Object instance, TRequest requestDto) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\ServiceRunner.cs:line 125
The initial Service has [Authenticate] attribute and subsequent methods have a combination of [Authenticate] and anonymous permissions.
It seems that I need to add something else to the request object so that whatever Dictionary it is looking at has the Key.
The Request DTO is as follows:
[Authenticate][Restrict(VisibleInternalOnly = true)]
[Route("/Movies/FromDb/{Id}", Verbs = "GET", Notes = "Requires a valid MovieId.", Summary = "Get Movie by Movie ID.")]
public class GetDbMovie : IReturn<DbMovieResponse>
{
[ApiMember(IsRequired = true, Description = "Required ID of Movie.")]
public long Id { get; set; }
[ApiMember(IsRequired = false, Description = "List of References to be included in result. Ex: 'Genres,Contributors,Videos' ")]
public string[] References { get; set; }
}
The initial DTO looks like:
[Authenticate][Restrict(VisibleInternalOnly = true)]
[Route("/AlphaMerge/CompareMovie", Verbs = "GET", Summary = "")]
public class CompareMovie : IReturn<CompareResponse>
{
[ApiMember(Description = "Entertainment Movie ID.", IsRequired = true)]
public long Id { get; set; }
[ApiMember(Description = "")]
public DateTime? AllowableIndexAgeDate { get; set; }
}
regards,
Bob