Note that there are some explanatory texts on larger screens.

plurals
  1. POPOST to ASP.NET WebAPI using Fiddler2
    primarykey
    data
    text
    <p>I have a class that models exactly the entity I have in the database. I have a stored procedure that takes in parameters for a new row and returns all the settings in the table which in turn populates my repository. I am able to see the results of GET, PUT and DELETE in the List of type Setting that is in memory. I am noticing first that even when I close Visual Studio and reopen and run the project, sometimes, the List is still in the state it was before. It is not repopulating from the database so I'm not sure why that is first of all... Secondly, I can't seem to get POST to work from Fiddler unlike the other HTTP verbs. I DO see the values from Fiddler show up in the code below but I get the error: Invalid URI: The format of the URI could not be determined. I get the same error if I pass an ID or not.</p> <p>Here is what I put into Fiddler: </p> <blockquote> <p>POST localhost:54852/api/settings</p> </blockquote> <p>Request Headers</p> <pre><code>User-Agent: Fiddler Content-type: application/x-www-form-urlencoded Host: localhost:54852 Content-Length: 149 </code></pre> <p>Request Body</p> <blockquote> <p>ID=0&amp;Category=Dried%20Goods&amp;Sub_Category=Other&amp;UnitSize=99&amp;UnitOfMeasureID=999&amp;Facings=true&amp;Quantity=true&amp;EverydayPrice=999.99&amp;PromotionPrice=111.11</p> </blockquote> <p>PostSetting function within my SettingsController</p> <pre><code> public HttpResponseMessage PostSetting(Setting item) { item = repository.Add(item); var response = new HttpResponseMessage&lt;Setting&gt;(item) { StatusCode = HttpStatusCode.Created }; string uri = Url.Route("DefaultApi", new { id = item.ID }); response.Headers.Location = new Uri(uri); return response; } </code></pre> <p>Should I create a new procedure that gets the MAXID from the database and use that as the NEW ID in the line above where a new ID is created?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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