PUT and POST – two similar methods, why ?

PUT and POST – two similar methods, why ?Kategorie: Dynamic SchedulingPUT and POST – two similar methods, why ?
eschuetze Mitarbeiter fragte vor 2 Jahren
Why are there two methods which are doing the same except the number of data ? Doesn’t it make sense to provide only one (probably “POST”) which can handle all ? POST /operations/forecastResults/update PUT /operations/{operationId}/forecastResult
1 Antworten
victor Mitarbeiter antwortete vor 2 Jahren

In HTTP the PUT method is used for changing a ressource. However, according to the HTTP specification for PUT, only a single resource can be changed with the method. See: https://tools.ietf.org/html/rfc7231

If several resources are to be changed at the same time, Bridge API offers the POST method. This reduces the number of method calls and ensures transaction security. This is because the forecast result would be inconsistent during the individual PUT calls. For example, if an application reads the forecast result in this time period since it was informed of the change by an MQTT event, this application would receive the inconsistent result. The entire forecast result should therefore be updated with POST, whereas the PUT method is used for rescheduling a single operation. By the way, this applies to both the forecast result and the planning result.

For the general use of the POST method in FORCE Bridge API please refer to https://docs.forcebridge.io/intro.html#http-methods-used-in-force-bridge-api