luckymarmot / Paw-Issues

The issue tracker repository for the Paw HTTP Client app.
33 stars 0 forks source link

Global Dynamic Variables #16

Closed kerrishotts closed 8 years ago

kerrishotts commented 10 years ago

I'm not entirely sure that this would be the best name for the feature, but let me explain what I'd like:

I have an API that sends new tokens on each request. The next request to the API must use that token, and it in turn receives another token, and so on.

Right now, I have Paw set up to pull this token from a specific request, but this then couples the requests together -- it'd be nice instead to have a less specific context where I could dump the token, and then have any other request use it. Furthermore, should another request respond with the same key path, it'd be nice to have Paw update this context, and so on.

Something like this:

Global Dynamic Variable: token
    Parsed Response (JSON)
        keypath: next-token

Any request:
    Headers:
        x-token: [Global Dynamic Variable: token]
    Response:
        { next-token: .... }

When the next-token response is received from any request, the global dynamic variable would then be updated such that further requests would receive the new value.

Right now, I handle this by following requests in specific orders so that they copy the value from the prior request. But it'd be nice not to be quite as tightly coupled all the time.

Ok -- final issue for today! Your app is amazing, and I absolutely love it -- this would just put me over the moon! :-)

mittsh commented 9 years ago

Thanks for the input @kerrishotts! (And sorry for the late answer). I believe this is now possible with Paw 2.1, as you may have multiple independent environments, you can simply have one that's just "global".

image

If that answers your needs. Feel free to close that ticket. Thanks!

kerrishotts commented 9 years ago

I'll give it a go. Thanks!

mittsh commented 9 years ago

Happy to help!

ndizazzo commented 9 years ago

@kerrishotts Did you ever find out how to set the value of a variable when you receive a response?

ndizazzo commented 9 years ago

Nevermind! I figured it out. For those also looking:

  1. Make sure you get a successful (20x) response from an endpoint.
  2. Go to the response view for the exchange
  3. Right click the field (I'm using JSON) name you want as a dynamic value
  4. Click 'copy as response body dynamic value'. screen shot 2015-03-25 at 4 47 50 pm
  5. Paste that into your environment/domain config value column. screen shot 2015-03-25 at 4 47 09 pm
mittsh commented 9 years ago

Hey @ndizazzo sorry for getting back late. Happy you figured that out, and thanks for the step-by-step instructions!

You can also go to the environments and in the value field right-click and pick Response > Response parsed body:

image

And configure the request + path manually:

image