karatelabs / karate

Test Automation Made Simple
https://karatelabs.github.io/karate
MIT License
8.12k stars 1.94k forks source link

Not able to validate my request before making a post call #511

Closed shuklasneha closed 6 years ago

shuklasneha commented 6 years ago

IMPORTANT: If you have a general question please use Stack Overflow instead where Karate has a dedicated "tag": https://stackoverflow.com/questions/tagged/karate

If you are sure you have found a bug, please make sure you follow the instructions here: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

shuklasneha commented 6 years ago

Script i am using looks something like this:

Scenario: Check for mandatory fields before registration Given url ApiAdminURL And path AdminPath And header apigateway-apikey = 'REGTEST' And header apigateway-basepath = 'Test' And request read('users2.json')

ptrthomas commented 6 years ago

no clear detail or instructions provided to replicate. closing.

shuklasneha commented 6 years ago

Apologies for not being clear. Actually i am facing issues in reading and validating my swagger which i am passing as my request body.

Before i make a post call with my swagger , i want to validate whether it contains certains mandatory fields or not.

For this, the script my running is

Scenario: Register API and chcek for mandatory fields Given url ApiAdminURL And path AdminPath And header apigateway-apikey = 'REGTEST' And header apigateway-basepath = 'lambdaTest' And request read('users2.json') * def requestbody = request* match requestbody.swagger.info.x-businessOwner == '#present'** When method post Then status 200

With this the error i am getting is: examples.Acesss.Access: [java.lang.RuntimeException: javascript evaluation failed: request, ReferenceError: "request" is not defined in at line number 1

Can you please help me fixing this

ptrthomas commented 6 years ago

kindly follow the instructions here: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

ghost commented 6 years ago

Before 'And request read('users2.json')'

shuklasneha commented 6 years ago

@CMouliNA Thanks for the help.