GarethOwen GarethOwen - 3 months ago 7x
JSON Question

How to insert entity over WCF-RIA-Services JSON endpoint

My WCF-RIA DomainService has an insert method that looks like this:

public void InsertWidget(WidgetDef widgetDef)

class WidgetDef
int widgetID;
string title;
int x;
int x;
// there are more properties, but I think you get the idea...

To access this through the JSON endpoint, I think I need to POST a changeset to the url:


I'm pretty sure I got the URL correct, because my request reaches the WidgetService.Initialize method, but then I get an exception in the server - which is no surprise because I don't know what the content of the request should look like.

My Question: What is the (JSON) format of a HTTP request's content for an insert operation?


Insert changeset for the example given would look like this:

                    "title":"the new title", 
            "Operation":2    // '2' for insert, '3' for update, '4' for delete 

Thanks to following blog post: