I am using entity framework code first. My entities and controller were generated by Visual Studio and have not been modified.
This issue seems to be that the DELTA for my patch request is null. The innererror on the web service is 'Object reference not set to an instance of an object' which is thrown on the Validate() function.
Here is my web service - this is a PUT service that behaves like a PATCH. This is to work around a bug with the Agentry framework which doesn't seem to work with Patch.
// PUT: odata/Device(5)
public IHttpActionResult Put([FromODataUri] long key, Delta<LineSeg> patch)
{
Validate(patch.GetEntity());
if (!ModelState.IsValid)
{
return NotFound();
}
LineSeg LineSeg = db.LineSeg.Find(key);
if (LineSeg == null)
{
return NotFound();
}
//note - put is acting as a patch due to agentry bug
patch.Patch(LineSeg);
try
{
db.SaveChanges();
}
catch (DbUpdateConcurrencyException)
{
if (!LineSegExists(key))
{
return NotFound();
}
else
{
throw;
}
}
return Updated(LineSeg);
}
Here is my request:
Header:
Content-Type: application/atom+xml
Body:
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<content type="application/xml">
<m:properties>
<d:RESULTS_ID m:type="Edm.Int64">399</d:RESULTS_ID>
</m:properties>