Introduction

Sample Rest Service can accept simple request and return response based on the input provided:

  • If the input contains and id that is greater than zero, then response returned with valid status and input is duplicated

  • If the input contains id that is zero or less, or missing and id, then response returned with invalid status and input is duplicated

HTTP status codes

Sample Rest Service tries to adhere as closely as possible to standard HTTP and REST conventions in its use of HTTP status codes.

Resources

cURL example

$ curl 'http://localhost:39579/process' -i -X POST \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/json; charset=UTF-8' \
    -d '{
  "id": 123,
  "name": "Hello"
}'

Request body

{
  "id": 123,
  "name": "Hello"
}
Path Type Description

id

Number

Id of the input that is bigger than 0

name

String

Name of the input

Response body

{"valid":true,"message":"Received: Input(id=123, name=Hello)"}
Path Type Description

valid

Boolean

Indicated whether input message was valid

message

String

Some message about the request processing

Invalid request

{
  "id": -987,
  "name": "Hello"
}

Invalid response

{"valid":false,"message":"Id should be > 0. Received: Input(id=-987, name=Hello)"}