hub.eb?material_id=527&track_id=532

Testing a REST Endpoint


A public REST service can be tested within Verj.io using the Test Rest Call button .

From the dialogue (see below) you can configure all the inputs (method, security, parameters, headers, body) of the HTTP request and submit to see the response.

Steps


1

Make a REST Resource with Endpoint getCode

2

Set the HTTP method to GET and the MIME Type to text/plain

3

Attach the following code to the Endpoint

switch (form.rest.getMethod()){
	case "GET":
		form.rest.setResponseBody("Ticket Code: 10829XA");
		form.rest.setResponseStatus(200);
		break;
	default:
		form.rest.setResponseStatus("405");
		form.rest.setResponseBody({
			msg: "No HTTP Method specificed or invalid HTTP Method used"
			})
		break;
}
4

Test the Public REST Service , then click Submit

See that it returns a 200 code.

 

5

Change the HTTP Method to POST

6

Retest the REST Service.

See that it returns a 405 code.

Current Module

Related