0
votes

I was trying to get into "http://localhost:8080/Twillio/smsService/index" from Grails view.

and I get errors like below.

HTTP Status 404 - "/WEB-INF/grails-app/views/smsService/index.gsp" not found.

My codes used for SmsServiceController.groovy is below.

package twillio

class SmsServiceController {

    def index () {}

    def smsService
    def twilioHttpEndpointBean
    def read = { withFormat { html {} } }

    def create = { SendSmsCommand cmd ->
        def validMessage = cmd.validate();
        log.debug "Incoming message is ${validMessage ? 'valid' : 'invalid'}"
        log.debug "Format is ${request.format}"

        withFormat {
            json {
                if (validMessage) {
                    def smsResponse
                    try {
                        smsResponse = smsService.send(cmd.destination, cmd.message)
                        render(contentType: "application/json") {
                            result(success: true)
                        }
                    } catch (Exception e) {
                        render(contentType: "application/json", status: 500) {
                            result(success: false, message: e.message)
                        }
                    }
                } else {
                    render(contentType: "application/json", status: 500) { result(success: false) }
                }
            }
        }
    }
}

class SendSmsCommand {
    String destination
    String message

    static constraints = {
        message(size: 1..140)
    }
}
1
Not that I tested but could be some form of conflict .. SmsServiceController Grails Controllers files must end with Controller. Grails Service files must end with Service. If it still is not working try renaming it to SmsSerController and see if that worksV H

1 Answers

1
votes

You have to place an index.gsp at grails-app/views/smsService/index.gsp