Reputation: 1
I'm trying to learn how to create my own Web API with Visual Studio 2012. I currently have two database tables set up through the Models I have below.
The Countries table is nice and simple. I can successfully POST a new entry with Fiddler. However, when it comes to trying to POST to the Players table, I'm getting a 500 Error. Of course, I have no idea where I'm going wrong.
Player.cs
public class Player
{
public Guid PlayerId { get; set; }
[Required]
public string Username { get; set; }
[Required]
public string Address { get; set; }
public string Address2 { get; set; }
[Required]
public string Town { get; set; }
[Required]
public string State { get; set; }
[Required]
public string Postcode { get; set; }
[Required]
public int CountryId { get; set; }
[Required]
public string Email { get; set; }
public string Telephone { get; set; }
public string Mobile { get; set; }
public DateTime? DateJoined { get; set; }
// Navigation properties
public Country Country { get; set; }
}
Countries.cs
public class Country
{
public int CountryId { get; set; }
public string Name { get; set; }
}
I have the following Content Type set in the Fiddler Request Header:
Content-Type: application/json; charset=utf-8
The data I'm trying to POST to the Player table is this:
{"PlayerId":"hfjdfk","Username":"TickledPink","Address":"My Address","Address2":"","Town":"Llanerchymedd","State":"Anglesey", "Postcode":"LL71","Email":"[email protected]","Telephone":"1234567","Mobile":"456789","DateJoined":"","CountryId":"1"}
Upvotes: 0
Views: 1382
Reputation: 549
I know little to nothing about Web API, but is "hfjdfk" a valid GUID?
Upvotes: 1