stefan-epic / Zabbix-6.0-Api

C# Library for Zabbix API 6.0
MIT License
9 stars 0 forks source link

Misused header 'content-type' Async #4

Open Sven286 opened 1 month ago

Sven286 commented 1 month ago

Hi,

I just started to use this nuget package for connecting to the api of my zabbix 6.0.23 installation. I created my new project as .Net 8 application and want to use asynchrone methods. Receiving all host groups gives me the following exception.

var groups = await _zabbixCore.HostGroups.GetAsync()

System.InvalidOperationException: Misused header name, 'content-type'. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects.
   at System.Net.Http.Headers.HttpHeaders.GetHeaderDescriptor(String name)
   at System.Net.Http.Headers.HttpHeaders.Add(String name, String value)
   at Zabbix.Core.ZabbixCore.SendRequestAsync[T](Object params, String method, String token)
   at Zabbix.Core.ZabbixCore.SendRequestAsync[T](Object params, String method)
   at Zabbix.Services.CrudServices.GetService`2.GetAsync(TEntityFilter filter)
   at Zabbix.Services.CrudServices.CrudService`3.GetAsync(TEntityFilter filter)

When I call the method synchroniously everything works fine. var groups = _zabbixCore.HostGroups.Get()

I Suspect the following line of code to be the issue, but I don't know why this piece is added: https://github.com/stefan-epic/Zabbix-6.0-Api/blob/39d73b09cfcc510e3f311523ba56e4234af7be21/Zabbix/Core/ZabbixCore.cs#L134

stefan-epic commented 1 month ago

I will look into this when I get the time thanks for making the issue :)