title: Retrieve value from [FromBody]JObject POST method function without using model class in C#
body: <p>I am writing one Web API in the POST method. In that post, values will come as [FromBody]JObject. How can I take values from JObject without using any model class? I tried many ways, but not fixed my problem.
  My code is,</p>
  <pre><code> [System.Web.Http.HttpPost]
      public IHttpActionResult SaveDetails([FromBody]JObject data)
      {
          try {
  
              JObject myJO = JObject.Parse(data.ToString());
              foreach (JProperty prop in myJO.Properties())
              {
                  JObject childJO = (JObject)prop.Value;
                //  List&lt;string&gt; keys = childJO.Properties().Select(p =&gt; p.Name).ToList();
                  Console.WriteLine(prop.Name + &quot;: &quot; + prop.Value);
              }
              
              return Ok(&quot;Success &quot;);
          }
          catch (Exception ex)
          {
              return Ok(&quot;Failed. &quot;+ex.Message);
          }
      }
  </code></pre>
  <p>And POST data is, <code>data:{&quot;companyCode&quot;:&quot;001&quot;,&quot;type&quot;:&quot;LVR&quot;,&quot;id&quot;:&quot;&quot;,&quot;LoginID&quot;:&quot;MVC01&quot;,&quot;fromDate&quot;:&quot;17 Mar 2021&quot;,&quot;toDate&quot;:&quot;26 Mar 2021&quot;,&quot;reason&quot;:&quot;The &quot;,&quot;leaveType&quot;:&quot;Annual leave&quot;,&quot;mode&quot;:&quot;New&quot;}</code>
  My Postman is like,
  <a href="https://i.stack.imgur.com/HIHlx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HIHlx.jpg" alt="Postman screenshot" /></a>
  Please give me a solution.</p>