Ross
Ross

Reputation: 11

Paw Extensions : Dynamic Value based on URI

I have an API that includes an account ID as part of the url (e.g. /account/7319310/report) where 7319310 is then account ID.

There are different credentials for each account, stored in MySQL although they could be stored in another manner if it made it easier.

I'd like Paw to automatically use the correct credentials based on the account parameter in the URI (it's always the second element) - is this possible?

Upvotes: 1

Views: 145

Answers (1)

Matthaus Woolard
Matthaus Woolard

Reputation: 2408

In paw you can use a regex Dynamic to extract the data you need from the url:

enter image description here

Paw does not have a direct connection to MySQL, you can make http request from a custom value but you would need a server running to push these request to the server. A better option would be to save the credentials into a flat json file.

{
    "1234334": {
                    "key1": 123456,
                    "key2": 345211
               }
}

With this saved you can load this json file in a Custom Dynamic Value: enter image description here

Here you can embed the extracted user id by using the regex dynamic value. inline in the code. Paw will reload the file on every request so you could set up a cron job to dump your database to this JSON file.

Upvotes: 1

Related Questions