Skip to content

Treat 201 Created response codes as successful requests#99

Merged
nywilken merged 1 commit intohashicorp:mainfrom
jerrykan:restful_status_codes
Jan 9, 2024
Merged

Treat 201 Created response codes as successful requests#99
nywilken merged 1 commit intohashicorp:mainfrom
jerrykan:restful_status_codes

Conversation

@jerrykan
Copy link
Contributor

@jerrykan jerrykan commented Sep 16, 2023

The Vagrant Cloud API responds to the creation of resources with 200 OK and the create version and create provider steps only check for this status code. However according to RESTful conventions the expected response for resource creation would be 201 Created. From MDN[1]:

The HTTP 201 Created success status response code indicates that the
request has succeeded and has led to the creation of a resource

and restfulapi.net[2]:

HTTP Status 201 indicates that as a result of HTTP POST request, one
or more new resources have been successfully created on the server.

To ensure that the post-processor works with alternative implementations that provide Vagrant Cloud like functionality, but adhere to RESTful conventions, it would be useful if the response code checks allowed a 201 status code.

[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201
[2] https://restfulapi.net/http-status-201-created/

The Vagrant Cloud API responds to the creation of resources with `200
OK` and the create version and create provider steps only check for this
status code. However according to RESTful conventions the expected
response for resource creation would be `201 Created`. From MDN[1]:

    The HTTP 201 Created success status response code indicates that the
    request has succeeded and has led to the creation of a resource

and restfulapi.net[2]:

    HTTP Status 201 indicates that as a result of HTTP POST request, one
    or more new resources have been successfully created on the server.

To ensure that the post-processor works with alternative implementations
that provide Vagrant Cloud like functionality, but adhere to RESTful
conventions, it would be useful if the response code checks allowed a
`200` status code.

[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/201
[2] https://restfulapi.net/http-status-201-created/
@jerrykan jerrykan requested a review from a team as a code owner September 16, 2023 05:56
@hashicorp-cla
Copy link

hashicorp-cla commented Sep 16, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Thanks for the enhancement.

@nywilken nywilken merged commit 1e0caec into hashicorp:main Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants