Exemplo n.º 1
0
        public ActionResult <TestResponse> Post([FromBody] TestRequestBody information)
        {
            try
            {
                var i = 0;
                _ = 9 / i;

                return(Ok(new TestResponse()
                {
                    intValue = information.i,
                    stringValue = information.s
                }));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Exemplo n.º 2
0
        private static void TestWithBody()
        {
            var b = new TestRequestBody()
            {
                i = 10, s = "hello"
            };

            var resp = WebApiUtil.CreateRequest(HttpMethod.POST, URL)
                       .AddBody(b)
                       .GetResponseOrException <TestResponse>();

            if (resp.ResponseType == WebAPIHelper.Models.ResponseType.ERROR)
            {
                Console.WriteLine(resp.Message);
            }
            else
            {
                Console.WriteLine("Nice");
                Console.WriteLine(resp.ReturnValue.stringValue);
            }
        }