Expand my Community achievements bar.

SOLVED

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

Avatar

Level 1

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?

1 Accepted Solution

Avatar

Correct answer by
Level 1

I found that solution.

They just check your User-Agent.

I added the header, it worked.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 1

I found that solution.

They just check your User-Agent.

I added the header, it worked.