0

New to Postman and Newman. I am iterating through a CSV data file, at times the values are few (20 or less) and at times they are great (50 or more). When iterating through large sets of values, 50 or more I receive a 429 error. Is there a way to write a retry function on a single request when the status is not 200?

I am working with the Amazon SP-API and reading through the documentation it appears as if there is nothing I can do about the x-amzn-RateLimit-Limit. My current limit is set at 5.0 I believe this is 5 requests per second.

Any advice would be helpful: a retry function, telling the requests to sleep/wait every X-amount, another method I am not aware of, etc.

This is the error I receive

{
  "errors": [
    {
      "code": "QuotaExceeded",
      "message": "You exceeded your quota for the requested resource.",
      "details": ""
    }
  ]
}
Freddy
  • 511
  • 2
  • 9
  • 19
  • 1
    Have you tried using something short-term like `--delay-request 2000` in the Newman command to add a delay to the requests? – Danny Dainton Nov 04 '22 at 22:53
  • How can I use that same command line option in my Newman code? Would I use it within the `newman.run({ ... })` function? Something like this `newman.run({ options.delayRequest = 3000, ... })`? – Freddy Nov 05 '22 at 01:16
  • I tried using `newman.run({options.delayRequest = 3000,...})` but received the following error `options.delayRequest = 3000` along with the following `SyntaxError: Unexpected token '.'` – Freddy Nov 05 '22 at 03:09
  • 1
    You should be able to use `delay` in the object, you dont use the word `options` when adding those flags. – Danny Dainton Nov 05 '22 at 06:59
  • I tried using `newman.run({delay = 3000, ... })` and also `newman.run({delayRequest = 3000, ... })` but I receive the following error `SyntaxError: Invalid shorthand property initializer`. I will keep researching more on this. – Freddy Nov 05 '22 at 15:39
  • I found out what the problem was from this [link](https://stackoverflow.com/questions/42006503/invalid-shorthand-property-initializer). I was using `=` instead of `:` to assign the properties (time). My final code looks like this `newman.run({delayRequest: 3000, ... })` and now it works. – Freddy Nov 05 '22 at 15:47
  • Ha, oh yeah. I should have probably noticed that – Danny Dainton Nov 05 '22 at 16:17

1 Answers1

1

@Danny Dainton pointed me to the right place. By reading through the documentation I found out that by using options.delayRequest I am able to delay the time between requests. My final code looks like the sample below—and it works now:

newman.run({
    delayRequest: 3000,
    ...
})
Freddy
  • 511
  • 2
  • 9
  • 19