Skip to content

Channels: Post channel with two empty required fields only validates one of them #53

@sphinix27

Description

@sphinix27

Description


In order to create or update a new channel there are required fields like name and type. If you send a post or put request without one of those param it would fail with a response saying that value is required. If you send a post or put request without both param the error response only display the type is required.

Environment


  • An Notifier Server installed with version 1.0
  • Operating System and version: Windows Server 2012 R2

Requirements


  • Rest Client: E.g. Postman.

API

  • Method: POST
  • Endpoint: /api/channels

Steps to Reproduce


  1. Open Postman.
  2. In Postman select 'POST' method for URL.
  3. In Postman Enter the endpoint to send a notification.. E.g. http://128.0.0.1/api/channels
  4. In Postman select Body tab. A Key - Value appears.
  5. In Postman under Body tab select the radio button with the 'raw' option.
  6. In Postman under Body tab press the drop down list button that says 'Text' and select the 'JSON(application/json)' option.
  7. In Postman in text area field write the body for send a notification. E.g.
 {     
    "configuration": {
      "url": "https://www.example.com/"
    }
  }
  1. Click on Send button. Receive a json response similar to this e.g.
{
    "timestamp": 1507725099872,
    "status": 400,
    "error": "Bad Request",
    "exception": "org.springframework.web.bind.MethodArgumentNotValidException",
    "errors": [
        {
            "field": "name",
            "code": "name.required",
            "defaultMessage": null
        },
        {
            "field": "type",
            "code": "NotNull",
            "defaultMessage": "may not be null"
        }
    ],
    "message": "Bad Request",
    "path": "/channels"
}

Actual Result


The status code is 400 and the response contains.

{
    "timestamp": 1507725099872,
    "status": 400,
    "error": "Bad Request",
    "exception": "org.springframework.web.bind.MethodArgumentNotValidException",
    "errors": [
        {
            "field": "type",
            "code": "NotNull",
            "defaultMessage": "may not be null"
        }
    ],
    "message": "Bad Request",
    "path": "/channels"
}

It only validates the type field.

Expected Result


It should validate both param name and type because both of them are required.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions