985 views

Description

The REST API Explorer returns sample scripts for RESTMessageV2 with upper-cased values for "setHttpMethod()". This causes the following exception:

request.setHttpMethod('GET');

java.lang.IllegalArgumentException: No enum const class com.glide.rest.outbound.HTTPOutboundMethod.GET
Caused by error in <refname> at line -1
java.lang.Enum.valueOf(Enum.java:196)
com.glide.rest.outbound.HTTPOutboundMethod.valueOf(HTTPOutboundMethod.java:6)
com.glide.rest.outbound.RESTMessageConfig.setHttpMethod(RESTMessageConfig.java:84)
com.glide.rest.outbound.RESTMessageClient.setHttpMethod(RESTMessageClient.java:132)
com.glide.rest.outbound.scriptable.ScriptableRESTMessageClient.jsFunction_setHttpMethod(ScriptableRESTMessageClient.java:102)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:597)
org.mozilla.javascript.FunctionObject.call(FunctionObject.java:504)
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1227)
org.mozilla.javascript.gen.c153513.call(<refname>:40)
org.mozilla.javascript.gen.c153513.exec(<refname>)
com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:233)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:105)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:72)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:63)
com.glide.script.Evaluator.evaluateString(Evaluator.java:91)
com.snc.automation.ScriptJob.execute(ScriptJob.java:38)
com.glide.schedule.JobExecutor.execute(JobExecutor.java:79)
com.glide.schedule.GlideScheduleWorker.executeJob(GlideScheduleWorker.java:177)
com.glide.schedule.GlideScheduleWorker.process(GlideScheduleWorker.java:124)
com.glide.schedule.GlideScheduleWorker.run(GlideScheduleWorker.java:56)

Changing the call to "request.setHttpMethod('get');" works as expected.

This occurs for all methods. GET / PUT / POST / PATCH / DELETE

Steps to Reproduce

  1. Select a table in REST API Explorer.
  2. Copy the "ServiceNow Script" example.
  3. Run example script in Scripts - Background.

Expected behavior: Results return.

Actual behavior: java.lang.IllegalArgumentException: No enum const class com.glide.rest.outbound.HTTPOutboundMethod.GET

Workaround

Change the generated script so that the HTTP method is lowercase, for example, request.setHttpMethod('get').


Related Problem: PRB646171

Seen In

Fuji Patch 5
Geneva Patch 5

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-01-24 22:14:41
Published:2015-09-21