DMTF / Redfish-Mockup-Server

A simple Python 3.4 program that can be copied into a folder at the top of any Redfish mockup and can serve Redfish requests on the specified IP/port.
Other
83 stars 37 forks source link

Subscription to EventService/Subscriptions - 204 response code #53

Open antesaj opened 5 years ago

antesaj commented 5 years ago

I'm attempting to use Node to send a POST request to /redfish/v1/EventService/Subscriptions with the following body:

        EventDestination: {
          EventFormatType: "MetricReport",
          SubscriptionType: "RedfishEvent",
          Destination: "http://localhost:8080/api/event_in"
        }
      }

I'm assuming something is wrong with my body format but I pulled this from the EventDestination schema. I'm getting a 204 response from RMS and am expecting a 201.

For the full function, see line 272-290 at https://github.com/andrewbossie/SER401-Redfish/blob/US-51-aantes/rfInsight/controllers/RoutesController.js

tomasg2012 commented 5 years ago

While a 201 is more appropriate of a response based on the specification, my interpretation of the spec reads that a 204 may be returned while still succeeding with a POST/PATCH in a few places (it just reads "if the service is unable to return a payload", rather than "service was unable to create/patch a payload", the former being a 2 code and the latter being some 4 code)

But yes, 201 should be returned in most of these cases if possible, I'm just not sure if it's 100% reliable when writing a client for it. Will likely still implement 201 but I would want to ask...

antesaj commented 5 years ago

Is my POST body format correct for a successful subscription?

Also, from https://www.dmtf.org/sites/default/files/standards/documents/DSP0266_1.6.1.pdf :

On success, the Event Service shall return an HTTP status 201 (CREATED) and the Location header in the response shall contain a URI giving the location of the newly created subscription resource.

tomasg2012 commented 5 years ago

In terms of the payload, you shouldn't be wrapping the content inside of "EventDestination :", it should just start with the curly braces. I believe some mock-ups have a mock subscription listed (like public-bladed?)

Thanks for the spec catch!

antesaj commented 5 years ago

Okay - great! I wasn't sure if I'm not meeting some 'minimum requirement' for subscription POST parameters.

mraineri commented 5 years ago

Just for clarity, this is what the body of the POST request should look like:

{
    "EventFormatType": "MetricReport",
    "EventTypes": [ "MetricReport" ],
    "Destination": "http://localhost:8080/api/event_in"
}

"SubscriptionType" is not needed since this is filled in by the service once the Event Destination resource is created. "EventTypes" is also a required property on Create operations.

antesaj commented 5 years ago

Thanks for the clarification!