0

We have a REST API endpoint which creates a presigned url (/createPresignedUrl) to upload file.

How that works is when API call is fired, server would create a presigned url and send that in response. Later, client would use this presigned url to submit the file to our server.

Should that endpoint(/createPresignedUrl) be GET/POST?

I personally find this as an action being performed by the server, and using the POST.

As its not fetching any actual resource from server, I haven't set this as GET.

I am on the crossroads right now. Should I go for GET/POST? It would be great to get some help here. Thanks.

asked Jul 1, 2021 at 9:45
1
  • 1
    It's POST. Absolutely. It has side effects, It creates a new resource, it should not be idempotent and it should not be cached. Otherwise you would have only one URL to upload files. Commented Jul 2, 2021 at 17:27

1 Answer 1

2

From developer.mozilla.org:
GET
The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.

POST
The POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server.

My Point of View:
From the client perspective it looks like retrieving data.
But from the server perspective its creating a new ressource and in the response parts of that ressource are returned.

Therefore i would use POST. It makes clear that this action will create something in the backend.

answered Jul 1, 2021 at 9:56
2
  • 2
    To add to this answer: the GET method is idempotent. You must be able to repeat the request without unintended side-effects and intermediate (proxy) servers can answer it with a cached value instead of sending the request to the actual application server. Commented Jul 2, 2021 at 6:04
  • Yes, I never saw GET in that perspective that it should be cache-able. Thanks. We are moving forward with POST for this. Thank you JanRecker and @BartvanIngenSchenau Commented Jul 6, 2021 at 14:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.