none
Posting to an OData service using json?

    Question

  • For the life of me I can't successfully post data to my OData service at sqlazurelabs, in order to create a new record.  If there is an example somewhere, using JSON, I would greatly appreciated it.

    I'm currently using anonymous access, but will lock it down once it's working.

    I keep getting a 415 (Unsupported Media Type) response from the server.

    Here is an example of what I'm doing...

    var oInData = {"field1":"value1",field2":"value2"};
    
    $.ajax({
    	url: g_oConfig.DataServer.ODataEndPoint + "/Inspections?$format=json",
    	type: "POST",
    	dataType: "application/json",
    	data: JSON.stringify( oInData ),
    	success: function(data) {
    		$("syncDebug").html(JSON.stringify(data));
    	},
    	error: function(jqXHR, textStatus, errorThrown) { 
    		$("syncDebug").html(
    			JSON.stringify(textStatus) + " | " + 
    			JSON.stringify(errorThrown));
    	},
    	cache:false
    });
    

    Wednesday, June 08, 2011 11:15 AM

All replies