How To Request With Multiple URL Using The Same Token

Hi All,

I am a newbie and I am not a coder/developer, just learning.
I have this task related to post API / postman.

The scenario as follows:

  1. Run API to sign in and get the token
  2. Edit the bearer token in a different API and run it (with that same token) for multiple URL

For eg. (after getting the token):
POST {{url}}api/v1/add/page-01
POST {{url}}api/v1/add/page-02
POST {{url}}api/v1/add/page-03
… …
POST {{url}}api/v1/add/page-99

I’ve tried to make a collection runner with that many API, so I don’t have to do it manually and eyeball/monitors the result. But in the next day, I will get a new token so I’ve to edit all that request one by one and this is very time-consuming and a waste.

How to do this in a more automated way? Can you guide me?

Thank you in advance.

Hey @denisdav, welcome to the community!

You can reference this article below that automates usage and renewal of an OAuth2.0 token.

1 Like

@allen.helton Even I was about to share the same article from my bookmarks :slight_smile: That’s life saver!!

@denisdav Please spare a min and similar issue is raised here.

Hi @allen.helton & @bpricilla, thank you for the guidance it helps related to the token.

And how to iterate the request for “x” amount times but with different URLs?
(Should I start a new thread or can I continue in this one to ask about this?)

For eg, rather than I add one by one in my collection runner:
POST {{url}}api/v1/add/page-01
POST {{url}}api/v1/add/page-02
POST {{url}}api/v1/add/page-03
… …
POST {{url}}api/v1/add/page-99

Can I just make something as a variable and iterate it 99x times?
Using this as a base request: POST {{url}}api/v1/add/page-“xx”

Is this feasible? Sorry for such a noob question.

Much appreciated. :slight_smile:

No worries @denisdav

I would recommend searching the forum for an answer on that. I’ve answered questions exactly like that maybe 10 times over the past year, they are out there and you won’t have to dig very hard :slight_smile:

Ok @allen.helton, many thanks for the support. Cheers!

Hi @denisdav, you may use collection runner and have URL as a variable. For that variable, you can pass data from csv or json and can have that number of iterations.
image
POST {{url}}api/v1/add/{{page}}

Sample json may look like

{
“page”:[
“page-01”,
“page-02”,
“page-03”,
“page-04”
]
}

thanks a lot @darkphoenix. this one completes my task. :slight_smile:

1 Like