The rate limit behavior differs when I call the API from curl or Postman, versus when I call it from within my program | Community
Skip to main content
July 9, 2023
Solved

The rate limit behavior differs when I call the API from curl or Postman, versus when I call it from within my program

  • July 9, 2023
  • 1 reply
  • 814 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by lion-game

I found that solution.

They just check your User-Agent.

I added the header, it worked.

1 reply

lion-gameAuthorAccepted solution
July 9, 2023

I found that solution.

They just check your User-Agent.

I added the header, it worked.