Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.Net MVC POST data not mapping to model
    text
    copied!<p>I'm trying to build a model to receive data from a HTTPPOST.</p> <p>The model is received and populated fine - except for <code>IList&lt;harsta&gt; harequest</code></p> <p>It shows as having a count of 1, but having null values against the fields: <img src="https://i.stack.imgur.com/dWKI7.png" alt="screenshot"></p> <p>My model is:</p> <pre><code> public class HAR { public int api_version { get; set; } public IList&lt;harsta&gt; harequest { get; set; } public class harsta { public int ta_id { get; set; } public string partner_id { get; set; } public string partner_url { get; set; } } ... ... } </code></pre> <p>The Post data for harrequest is (should have 2 entries):</p> <pre><code>[{"ta_id":97497,"partner_id":"229547","partner_url":"http://partner.com/deeplink/to/229547"}, {"ta_id":97832,"partner_id":"id34234","partner_url":"http://partner.com/deeplink/to/id34234"}] </code></pre> <p>A screenshot from PostMan shows the form encoded data that is sent to the controller: <img src="https://i.stack.imgur.com/Uo9qW.png" alt="ss2"></p> <pre><code>Example Request (this is the example provided on the 3rd party website) POST http://partner-site.com/api_implementation/ha BODY api_version=4 &amp;harequest=[{"ta_id":97497,"partner_id":"229547","partner_url":"http://partner.com/deeplink/to/229547"},{"ta_id":97832,"partner_id":"id34234","partner_url":"http://partner.com/deeplink/to/id34234"}] &amp;start_date=2013-07-01 ... &amp;query_key=6167a22d1f87d2028bf60a8e5e27afa7_191_13602996000 </code></pre> <p>I'm sure it's not mapping to my model, because of the way I've setup my model here:</p> <pre><code> public IList&lt;harsta&gt; harequest { get; set; } public class harsta { public int ta_id { get; set; } public string partner_id { get; set; } public string partner_url { get; set; } } </code></pre> <p>Have I setup the model incorrectly, to receive the JSON data from the harequest field in the POST?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload