Coding with C# and .NET: JSON Deserialisation

preview_player
Показать описание

Using Utf8JsonReader to deserialise JSON.

Рекомендации по теме
Комментарии
Автор

Hi Steve,
I've build dotnet5 Web api project and need to allow the access through nuget package. details as below. When i tested the methods via swagger & postman all fine. but from wenproxy project I get error 404. I only see the Content-Type difference, but with the same header values if I test via postmann it works.

The problem only occurred when complex items are as parameters. What do I missed? How can I resolve this issue in BEst Practise way?
Thanks a lot in advance

Details:

Api Project => dotnet5

Web proxy nuget => target to NET461 & Netstandard2.0


Api Request from NETSTANDARD2.0:


{Method: POST, RequestUri: '.../getDocuments', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
{
Accept-Language: de-AT
Accept-Language: *
Authorization: Bearer ...
Content-Type: application/json; charset=utf-8
}}

Response :

{StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Transfer-Encoding: chunked
Date: Thu, 04 Mar 2021 09:45:32 GMT
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
}}


Swagger:

curl -X POST ".../GetDocuments" -H "accept: */*" -H "Authorization: Bearer ..." -H "Content-Type: application/json-patch+json" -d "{\"limit\":50, \"offset\":0}"



ex: working with simple type parameters

[HttpGet]
public async Task<IActionResult> Get(string idDocument)
{
var result = await
if (result.IsSuccess)
return Ok(result.Data);

return NotFound(result);
}


Not working with complex type parameters


[HttpPost("GetDocuments")]
public async Task<IActionResult> GetDocuments(FilterModel model)
{
var result = await
return Ok(result.Result);
}

menakasattmann
welcome to shbcf.ru