The JsonResponse type is not a problem. I don’t understand why they are used though, since they are basically a JSON object with one attribute “Value” which contains another JSON object that is “stringified”, meaning it’s a string full of backslashes everywhere… Why not just return that object instead? - but again, this is not a problem, I’m handling that.
The problem is the “BlockHash_” attribute. I don’t see any apparent naming conflict since the real attribute of that object (in the proto) is called “block_hash” - nothing else it called that.
The problem arise when I want to create a REST API that calls the gRPC API. I wish to call my own API with a request object that contains some attributes of which one is the request object for the gRPC API.
Many of the gRPC API methods take a BlockHash object as request { “block_hash”: “some-hash-value” }, that is why I was trying to work with that first, since it is also a very simple object with only one attribute.
So the request for my own API could look like this:
{
"attribute_a":"some text",
"attribute_b":true,
"attribute_c":300,
"grpc_request":{
"block_hash":"some-hash-value"
},
"attribute_d":256.66
}
The attributes a, b, c, and d are attributes for my own API, but the “grpc_request” attribute is the request object for the gRPC API.
So in order for my API to call the gRPC API, I need to deserialize this object in order to perform the gRPC method call with the correct type of argument - and this is where things go wrong.
Because the value of the above “grpc_request” attribute, does not turn into that of a BlockHash object as described in the proto which was { “block_hash”: “some-hash-value” }, which means that my attempt to make that JSON into a BlockHash object results in { } and empty object.
If however, I send this instead, then it works.
{
"attribute_a":"some text",
"attribute_b":true,
"attribute_c":300,
"grpc_request":{
"BlockHash_":"some-hash-value"
},
"attribute_d":256.66
}
Unfortunately this breaks the whole idea of what I’m doing, since I need to redefine the arguments for the gRPC API and this was just a request with one attribute… what happens when the request is an object with multiple attributes of which some are objects etc. etc.
At the same time, I tried to send a request { “block_hash”: “some-hash-value” } to the gRPC API, via the BloomRPC client, and that works.
So it seems that the problem lais with the way Visual Studio generates C# code from .proto files, and I’m not sure what to do about it, if I can do anything about it at all.