Aman Shah
Aman Shah

Reputation: 1

How to use FormData while testing API post request in opentest

Hi I am getting below error while using FormData in Post Method for opentest

my code:

var data = new FormData(); data.append("name", "test")

and I am getting below error:

at org.getopentest.base.TestActor.evalScript(TestActor.java:1441)
at org.getopentest.base.ScriptAction.run(ScriptAction.java:32)
at org.getopentest.base.TestActor.executeAction(TestActor.java:1527)
at org.getopentest.base.TestActor.executeActionByDef(TestActor.java:1695)
... 4 more
Caused by: javax.script.ScriptException: ReferenceError: "FormData" is not defined in <eval> at line number 1
    at 

jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:454) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406) at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402) at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155) at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) at org.getopentest.base.TestActor.evalScript(TestActor.java:1427)

Upvotes: 0

Views: 125

Answers (1)

Adrian Theodorescu
Adrian Theodorescu

Reputation: 12327

The FormData object is only available in web browsers and is not part of the OpenTest API. If you are trying to send a request using the HttpRequest keyword, you should be able to build this simply by concatenating the key/value pairs for the form fields and their values this way:

field1=value1&field2=value2&field3=value3

More details here.

Upvotes: 0

Related Questions