api - How Do I Perform a DotNetNuke WebAPI Update/Delete? -


i've got dnn module i've created has no problem retrieving data server using webapi. however, when try perform update, continue errors no matter try. viewing in firebug, can data being posted:

!(http://www.virtual-essentials.com/personal/firebug1.png)

but, when debug, see nothing default (null.setnull) values (bool = false, int = 0, string= empty).

then, of course response no , results in this: !(http://www.virtual-essentials.com/personal/firebug2.png)

i've tried every combination of things can think of, cannot figured out , i'm going nuts.

here ajax call: //u//operation - update self.updatetestimonial = function (objitem) { var method = "updatetestimonial"; self.updatepublishstatus(objitem);

    $.ajax({         type: "post",         contenttype: "application/json",         url: sf.getserviceroot('virtualessentials/testimonials') + "testimonialweb/" + method,         beforesend: sf.setmoduleheaders,         data: ko.tojson({ item: new testimonialinfodto(objitem.testimonialid(), objitem.ispublished())}),         success: function (data) {             self.useralerttext(objitem.testimonial() + ' changes have been saved');             //self.gettestimonials(); //get new data after updates         },         error: function (xhr, status, error) {             self.useralerttext('oops! error updating ' + objitem.testimonial + '<br />' + (error));             //put status             self.updatepublishstatus(objitem);          }     }); }; 

here webapi controller call:

    [httppost]     [dnnmoduleauthorize(accesslevel = securityaccesslevel.edit)]     public system.net.http.httpresponsemessage updatetestimonial(testimonialinfodto item)     {         try         {             controller.testimonialcontroller objcontroller = new controller.testimonialcontroller();             objcontroller.publishtestimonial(item.testimonialid, item.ispublished);         }         catch (httpresponseexception ex)         {             return ex.response;         }      } 

any on sincerely appreciated!!

it never fails find solution ask help. pulled source code core journal module , saw posting post data bit differently. modified json string sending , went through. thought since parameter method was:

 updatetestimonial(testimonialinfodto item) 

that expecting:

 {"item":{"testimonialid":14,"ispublished":false}} 

but, turns out wants is:

{"testimonialid":14,"ispublished":false} 

anyhow, here did make changes; changed way built data post.

    var data = new testimonialinfodto(objitem.testimonialid(), objitem.ispublished());      $.ajax({    ...     data: ko.tojson(data), 

i hope helps someone. there isn't lot of dnn webapi documentation out @ point.

thanks! briana


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -