Something very strange is happening. Let's assume I wrote a for loop in a script that runs curl commands.
for i in {1..5}
do
curl -X GET https://usermanagement.adobe.io/v2/usermanagement/users/...@AdobeOrg/0 \
--header "Authorization: Bearer ey..." \
--header 'X-Api-Key: ...'
done
This code works, of course, not weird.
However, my program got the error too many request, why?
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
for i := 0; i < 5; i++ {
request()
}
}
func request() {
req, _ := http.NewRequest("GET", "https://usermanagement.adobe.io/v2/usermanagement/users/...@AdobeOrg/0", nil)
req.Header.Set("Authorization", "Bearer ey...")
req.Header.Set("X-Api-Key", "...")
client := new(http.Client)
res, err := client.Do(req)
if err != nil {
fmt.Println(fmt.Errorf("error %v", err.Error()))
return
}
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
if res.StatusCode != 200 {
fmt.Println(fmt.Errorf("something happens %v", string(body)))
return
}
fmt.Println("Done!")
}
If I am mistaken or if there are facts that I am not aware of, please inform me.
This code displays 'Done!' only once, and from the second time onward, it results in "something happens" (but it was "too many request").
So why are these so difference?