Rest API put method returns bad request

Hi!
I’m trying to interact with ROS 7.14.3 using C# HttpClient. With GET I can easily parse things to record classes. However when I’m trying to use PUT, I have some problems. Example:

public record NAT
{
    [JsonPropertyName("chain")] public string Chain { get; set; }
    [JsonPropertyName("action") public string Action { get; set; }
}

        gw_client.BaseAddress = new Uri("http://192.168.0.15:80/rest/");
        var result = await gw_client.PutAsJsonAsync<NAT>("ip/firewall/nat", natRule);

This generates

{“chain”:“dstnat”,“action”:“accept”} PUT

But I get

{“detail”:“missing =chain=”,“error”:400,“message”:“Bad Request”}

as a response. Sending same JSON body with Postman creates rule no problem. What can cause this problem?

Why not get the request header and the data ?
So you see that is correct format from your app.
You could use nc like this

sudo nc -l 80

and change your file like this

gw_client.BaseAddress = new Uri("http://127.0.0.1:80/rest/");

So you see like the header

Content-Type: application/json

Or here you see how to provide
Content-Type
https://stackoverflow.com/questions/10679214/how-to-set-the-content-type-header-for-an-httpclient-request

And I think you can do something like this on PowerShell in windows.

$endpoint = new-object System.Net.IPEndpoint([ipaddress]::any,80)
$listener = new-object System.Net.Sockets.TcpListener $endpoint
$listener.start()
$data = $listener.AcceptTcpClient()
Write-Output $data