05.11.2018 - 09.11.2018 arası işler

Dotnetcore dapper kullanımı Link

Dotnet basic authentication Link

Dotnet core basic authentication Link

Aspnet webapi best practices Link

Getting curl to output HTTP status code? Link

how to check http status codes with curl Link

Ubuntu üzerinde redis kurulumu Link

Dotnet üzerinde  redis kullanımı Link

Task.Delay ile Thread.Sleep arasındaki farkı okumak için Link

Restsharp ile basic authentication örnek kod Link

Windows üzerinde docker kullanımı Link

Javascript datetime tutorial Link Link Link

Calling web api from dotnet client Link


ASP.NET Core Web API - POST JSON


 [HttpPost("Create")]        
        public async Task<HttpResponseMessage> Create([FromBody] JObject data)
        {            
            if (data == null)
                return new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest, ReasonPhrase = "POST body is null" };

            try
            {
                await Db.CreateItemAsync(data);
                return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, ReasonPhrase = "Saved" };
            }
            catch (Exception ex)
            {
                return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, ReasonPhrase = $"Document could not be created: {ex.InnerException}" };
            }
        }


function SaveDocument() {
    
    var myData = JSON.stringify({ "userName": "bob", "password": "123" });

    $.ajax({
        url: url,
        type: "POST",
        contentType: "application/json",
        dataType: "json",
        data: myData,

        success: function (result) {
            console.log(result);
        },

        error: function (xhr, resp, text) {
            console.log(xhr, resp, text);
        }
    });
}

Yorumlar

Bu blogdaki popüler yayınlar

22.06.2020 - 26.06.2020 arası işler

Asp.net RestSharp ile data post etmek

List Box Item içindeki elemanları aşağı veya yukarı taşımak