coldfusion - How to make a REST delete method with cfhttp -
coldfusion - How to make a REST delete method with cfhttp -
i have never done before , when need arise, things not working. have send id delete db record restful service. here code trying:
<cfhttp url="http://127.0.0.1:8500/rest/test/something" method="delete" port="8500" result="qryres1"> <cfhttpparam type="body" value="36"/> </cfhttp> and in rest function
remote function somename() httpmethod="delete"{ var testid = tostring(gethttprequestdata().content); //make db phone call delete homecoming testid; } the result comes blank [empty string]. not able retrieve sent value in function. missing? edit: 1 different related cf rest, necessary convert query array before sending client? straight serializing won't solve purpose same way?
you may want take @ deleteuser() in http://www.anujgakhar.com/2012/02/20/using-rest-services-in-coldfusion-10/ illustration of how back upwards delete in rest api style.
remote function deleteuser(numeric userid restargsource="path") httpmethod="delete" restpath="{userid}" { var response = ""; var qry = new query(); var userqry = ""; qry.setsql("delete tbluser id = :userid"); qry.addparam(name="userid", value="#arguments.userid#", cfsqltype="cf_sql_numeric"); userqry = qry.execute().getprefix(); if(userqry.recordcount) { response = "user deleted"; } else { throw(type="restsample.usernotfounderror", errorcode='404', detail='user not found'); } homecoming response; } as 2nd part of question, it'd best first turn query array of structs first unless you're using cf11 you. see: http://www.raymondcamden.com/index.cfm/2014/5/8/coldfusion-11s-new-struct-format-for-json-and-how-to-use-it-in-coldfusion-10
the default json construction query in cf 8 10 designed <cfgrid> in coldfusion on top of adobe's discontinued spry framework.
rest coldfusion coldfusion-10
Comments
Post a Comment