Copy link to clipboard
Copied
I'm lost. I am attempting to pass a FORMFIELD-parameter via the DELETE-method to a REST-function using script language.
I want to delete a resource. I get "Method not allowed", only "GET,OPTIONS,HEAD", so the DELETE-method is not understood.
I would apprechiate any meaningful input.
---------(service call)-------------
form.CategoryIDDelete = "X,Y,Z"
httpSvc = new http();
httpSvc.setMethod("DELETE");
httpSvc.setCharset("utf-8");
httpSvc.addParam(type="formfield", name="CategoryIDDelete", value="#FORM.CategoryIDDelete#");
httpSvc.setUrl("http://data.myDomain.net/rest/restService/categories");
res = httpSvc.send().getPrefix();
writeDump(res);
writeDump(FORM);
------------------------------------
...calls the rest service function in the registred REST component.
Here I call CategoryIDDelete "catIDs".
---------(service function)---------
remote Array function delCategory(string catIDs restArgSource="FORM") httpMethod="DELETE" restpath="{catIDs}" produces="application/json" {
var resp = [];
if (len(catIDs) > 0) {
...
}
return resp;
}
-------------------------------------
I am uncertain about many things; restArgSource="FORM", restPath="{catIDs}", and why DELETE is not an allowed method.
Copy link to clipboard
Copied
I thought you are on ColdFusion 11, which is still in Beta. However, I checked the http documentation and verified that all of your code is within existing syntax.
Why 'post' a form parameter when the method is 'delete'? To delete, I would just do something like
httpSvc = new http();
httpSvc.setUrl("http://data.myDomain.net/rest/restService/categories");
httpSvc.setMethod("DELETE");
res = httpSvc.send().getPrefix();
writeDump(res);
Message was edited by: BKBK
Copy link to clipboard
Copied
I have now had a good look at your code. It is unclear to me why your http is doing the delete. That is the REST service's job. So, you could just get the http service to do a Get, or Post, if you wish to pass a parameter:
httpSvc = new http();
httpSvc.setUrl("http://data.myDomain.net/rest/restService/categories");
httpSvc.setMethod("Get");
/*
httpSvc.setMethod("Post");
httpSvc.addParam(type="formfield", name="CategoryIDDelete", value="#FORM.CategoryIDDelete#");
*/
res = httpSvc.send().getPrefix();
writeDump(res);
Also, shouldn't there be a comma to separate the arguments catIDs and restArgSource?
delCategory(string catIDs restArgSource="FORM")
The attribute restpath="{catIDs}" implies the respath will be evaluated from the value of catIDs. However, I do not understand why you need a form.