My Web Api Core Controller Method looks like this
public void Post(Sample sample) {
_sampleService.CreateSample(sample);
}
Sample POCO looks like this
public class Sample : BaseEntity
{
public string BarCode { get; set; }
public DateTime CreatedAt { get; set; }
public virtual User CreatedBy { get; set; }
public virtual Status Status { get; set; }
}
on the client side sample object is only sending 2 properties for now and looks like this.
{barcode:"1234"createdAt:"2017-06-07"}
and the http post looks like this
createSample(sample: Sample) {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
return this.http.post(AppConstants.createSample, JSON.stringify(sample), { headers: headers })
.map((res: Response) => res.json()); }
so if i user headers i get No 'Access-Control-Allow-Origin' header is present
if i not use headers i get (Unsupported Media Type)
any idea whats going on here.
UPDATE
so I followed instructions as in first answer and looks like CORS is not set property but now JSON is not being converted to C# Object