What HTTP error code for failure to create a new resource because a parent entity is gone

前端 未结 2 1847
-上瘾入骨i
-上瘾入骨i 2021-02-13 13:13

Say i have an API exposing two related resources, Company which has many Employees.

Say I create a new Company: POST http://domain/api/company/ which returns something l

2条回答
  •  借酒劲吻你
    2021-02-13 13:53

    I ran in the same situation here.

    After evaluating the HTTP Status code options, it appears to me the best option is to return a 424 Failed Dependency

    The 424 (Failed Dependency) status code means that the method could not be performed on the resource because the requested action depended on another action and that action failed. For example, if a command in a PROPPATCH method fails, then, at minimum, the rest of the commands will also fail with 424 (Failed Dependency).

    From RFC

提交回复
热议问题