Here I want to fetch the multiple IDs from the postman and I'm confuse which method (POST, GET, PUT, DELETE) should I have to use for this. From these IDs I have to retrieve the data from database.
Can I use Get
method and using query string
then the url will be
localhost:8080/name?ids=1,2,3,4
Can anyone please tell me that I'm thinking is right or not and If not, then What should I have to used for this.
Surely you can do it GET
method. And it depends on how you are dealing with the ids
, the best way to do it would be sending the values as an array. Something like this
localhost:8080/name?ids=[1,2,3,4]
Then you can retrieve that ids with something like this:
ids := r.URL.Query().Get("ids")
log.Println(ids)
And you will get the data like this [1,2,3,3]
, but again it depends on how you are dealing with the data.