ASP.NET web API C# JSON de/serializing issue

Hi,

I am aiming to create a Grasshopper component which communicates with a web API without using Rhino.Compute. I am using a ASP.NET web API template running on a local server.

I was able to create successfully multiple requests (number addition, moving point) however if I try to send a brep as a JSON to the web API via HttpGet request I am getting an error 500 as a response in the Grasshopper component. However if I debugg the API in a browser (I write the JSON dirrectly in the query) it returns a correct brep as a JSON.

Any tips what am I doing wrong? Thank you.

StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Transfer-Encoding: chunked
  Date: Tue, 31 Oct 2023 18:17:13 GMT
  Server: Microsoft-IIS/10.0
  X-Powered-By: ASP.NET
}

Grasshopper component sending requests to web API (left),
ASP.NET Web API template with controllers (right)

I’d throw a try catch statement to catch any errors, and come up with some logging to capture var values (i.e. if a var object is null)

Pseudo:

[HttpGet(“simulate-error”)]
public IActionResult SimulateError()
{
try
{
// Simulate an exception (e.g., divide by zero).
int result = 1 / 0;
return Ok(result);
}
catch (Exception ex)
{
_logger.LogError(ex, “An error occurred in the API endpoint.”);
return StatusCode(500, “An error occurred”);
}
}

Issue solved by changing the request to POST request and converting the StringContent to an Object.