json - Grails RESTful Controller. POST hits index() instead of save() -


I am trying to create a cool controller in Grails 2.3.4. I'm actually following the documentation, however, whenever I try to post, I always suppress the index. The only way to save () to work is to remove the index method. It does not make sense to me.

I have tried to expand both RestfulController superclass:

and implement their own ways:

And yet, when I have my URL Posting on, this index only hits the method, whether it is expanding in a pure controller, or in my own method

I have "/ api / lab" (controller: "Laboratory") UrlMappings.groovy have json: [ 'application / json', 'text / json '], defines my mime types

I tried to add static allowed method of your controller and remove the [save: "Post" update: "PUT ", Delete:" delete "] .

But I'm carrying out their own controller when it is my controller:

  class LabController {static responseFormats = [ 'Jason'] def Upyogkrtasrvist Diaf Index for (int max) {params.max = Math.min (maximum ?: 10, 100) patient patient = user Sewakupyogkrtakpetiant render Rogilabkfindalebatiatt Andtip (patient, Labtaipkfin DByName (LabType.LAB_TYPE_INR)) JSON} Save @transnational DRF in the form () {Patient = patient To enable service counter user Piactiaiti Labtaip Inrtaip = Lab type. FIDBAM (LabTap.LLPAPDINR) Boolean LabAldexExists = PetTab.FindbitTealBadTet and Type (Patient, Request.JSON.LabDet, InrType) (labAlreadyExists) {render {Result: "Lab already exists"} PatientLab as JSON return PatientLab = new PatientLab () patient Lab.patient = patient patient Lab.origin = LabOrigin.MOBILE_APP patientLab.type = inrType patientLab.result = Request.JSON.result patientLab.measurement = UnitType.findByUnit (UnitType.UNIT_TYPE_NONE) patientLab.labDate = New Date ()}}   

This is my controller while extending the RestfulController:

  enhances classroom LabController RestfulController {static Pratikriyaprarup = [ 'json'] LabController () {super (Rogeelab)}}    

 " / api / lab "(Controller:" Lab ")       "/ api / labs" (resource: "lab")   

its Use your post / API / Lab to save () method if You do not want to use plural in your rest controller, you can use resource instead, but most of the time I go with plurality, I have a list of those methods that I support I am doing and I do it in : ['index', 'show'] allows me to easily support certain actions.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -