Difference between GetResultAsync and GetStateAsync

I’m using the gRPC client to get a partitioned projection but I can’t figure out the difference between the methods GetResultAsync and GetStateAsync.

The GetStateAsync always returns an exception:

System.Text.Json.JsonReaderException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.

When should I use it?

Sorry for the very late response.

GetStateAsync implies that you call the outputState function in your projection. See more here: https://developers.eventstore.com/server/v21.2/docs/projections/user-defined-projections.html#user-defined-projections-api

GetResultAsync implies the state of your projection once it got completed. Mind you if you use the transformBy function, the result would whatever returned by that function.