Debug - Find the route of my http Rest - Grails

Asked

Viewed 25 times

0

I have a call POST http Rest, where I get a file my parameters and mount it to log in, I believe it is talking because the route I am mounting this wrong, It is missing some bar, or capital letters and minuscules.

        log.info "* Login"

        def sf_login_domain = grailsApplication.config.crm.sf_login_domain
        log.debug "**  sf_login_domain: ${sf_login_domain}"
        def consumer_key = grailsApplication.config.crm.consumer_key
        log.debug "**  consumer_key: ${consumer_key}"
        def consumer_secret = grailsApplication.config.crm.consumer_secret
        log.debug "**  consumer_secret: ${consumer_secret}"
        def auth_username = grailsApplication.config.crm.auth_username
        log.debug "**  auth_username: ${auth_username}"
        def auth_password = grailsApplication.config.crm.auth_password
        log.debug "**  auth_password: ${auth_password}"
        def retornoLogin
        def access_token = ""
        def instance_domain = ""

        //Request Access_token and instance domain for work
        def http = new HTTPBuilder(sf_login_domain)
        def postBody = [
            grant_type: 'password',
            client_id: consumer_key,
            client_secret: consumer_secret,
            username: auth_username,
            password: auth_password
        ]
        try {
            http.post( path : 'EfetuarLogin',
                body : postBody,
                requestContentType: URLENC) { resp, json ->
                    access_token = json.access_token
                    instance_domain = json.instance_url + "/"
            }
            //INSERIR AQUI MEU log.debug "rota ${variavel com a rota}"
            log.debug "**  access_token: ${access_token}, instance_domain: ${instance_domain}"
            coss.Parametro.executeUpdate("update Parametro p set p.valor='$access_token' where p.chave='ACCESS_TOKEN_SALES_FORCE'")
            coss.Parametro.executeUpdate("update Parametro p set p.valor='$instance_domain' where p.chave='INSTANCE_DOMAIN_SALES_FORCE'")
            retornoLogin = ['access_token':access_token, 'instance_domain':instance_domain]
        }
        catch(Exception e){
            log.error "** Error code: ${e}"
            log.error "** Post form: ${postBody}"
        }
        return retornoLogin

I know that the route is mounted with what it contains in the variable sf_login_domain added to my path EfetuarLogin, to become something like http://domanin.com/EfetuarLogin, but I can’t tell if that’s what’s being mounted on my Rest, does anyone know how I can verify this?

  • Use the Postman

  • I know how my route has to be mounted, including I know by Postman, I want to know how it is being assembled by my request.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.