Skip to content

Can't seem to use the "req" object in moco groovy scripts #34

@royteeuwen

Description

@royteeuwen

I'm trying to use an example of the api docs of moco:

stubs.server.request(by(uri("/template"))).response(template("${req.version}"));

But I get following response:

16.07.2020 14:54:51.178 *ERROR* [sling-oak-observation-14] com.cognifide.aem.stubs.core.ConfigurableStubManager Cannot execute AEM Stubs script at path '/conf/stubs/moco/websites/example/get.stub.groovy'!
groovy.lang.MissingPropertyException: No such property: req for class: Script1

What I actually want to achieve is the following:

stubs.server
    .get(by(uri("/some-api")))
.response(repository.readText(template("./file_${req.queries['id']}.json")))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions