2
votes

I am attempting to get access to the underlying JSON object (request body) within a service call in service stack. The reason I wish to do this is to create a PATCH version of an existing service, which will only attempt to update fields that were in the JSON. Seems simple enough:

    public object Patch(AddUpdateContactRequest request)
    {
        var json = this.Request.GetRawBody();
        var keysToUpdate = JsonSerializer.DeserializeFromString<Dictionary<string, string>>(json);

        return Put(request);
    }

However, I get an exception from service stack when GetRawBody() is called (when service stack is calling in to .NET core):

Message: "Could not load type 'Microsoft.AspNetCore.Http.Internal.BufferingHelper' from assembly 'Microsoft.AspNetCore.Http, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'." Source: "ServiceStack" StackTrace: " at ServiceStack.Host.NetCore.NetCoreRequest.GetRawBody() in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\NetCore\NetCoreRequest.cs:line 211" TargetSite: {System.String GetRawBody()} TypeName: "Microsoft.AspNetCore.Http.Internal.BufferingHelper"

It seems to be referencing version 3.0 of Microsoft.AspNetCore.Http, but this version does not have the namespace Microsoft.AspNetCore.Http.Internal.BufferingHelper. It looks like a version mismatch issue, but I cannot seem to make it work. I cannot see any dll version conflicts locally, I am implicitly referencing the latest version of .NET core and have the latest SDK/hosting package installed.

1

1 Answers

1
votes

If this is .NET Core 3.0 this is due to a breaking change in .NET Core 3.0 which has been resolved in the latest v5.7.1 packages on MyGet.