Kris Java
Kris Java

Reputation: 3

Unable to pass JSONObject from Grails Controller to the Grails service

Is something I am doing wrong here, I am unable to pass the JSON Object to the Grails Service from Grails Controller.

class SampleController {

  def sampleService

  def updateProduct() {
    def jq = request.JSON
    sampleService(jq)
  }    
}

class SampleService { 

  def updateProduct (JSONObject requestJSON) {
    if (!requestJSON) {
        return null;
    }
  }
}

No signature of method: com.SampleService.call() is applicable for argument types: (org.codehaus.groovy.grails.web.json.JSONObject) values:

Possible solutions:

wait(), any(), wait(long), any(groovy.lang.Closure), each(groovy.lang.Closure), find().

Stacktrace follows:

Upvotes: 0

Views: 1125

Answers (1)

codelark
codelark

Reputation: 12334

You're trying to call the service object as a method.

sampleService(jq) should be sampleService.updateProduct(jq)

Upvotes: 2

Related Questions