Skip to main content
Best answer

Extract part of a python response

  • November 22, 2021
  • 2 replies
  • 234 views

Hello,

I have a step in my Zap where I need to retrieve a bearer token to use for a later step. This token can be retrieved within a response from a python request.

My response in Zapier looks like this:

 

output_missing

Please define output or return early.

id

8KzjgJ7iu86HBhkCxXu5L8hSoc5sD3Qq

runtime_meta

memory_used_mb

47

duration_ms

857

logs

1

{"expiresAt":"2021-12-22T02:13:20Z","cultureId":1,"companyAccountId":20,"userAccountId":47,"newUrl":null,"refreshToken":"z8+7NQrtekQ35vrR6l03cn+V4mL6CBazO0WACqYjzM0=","token":"{TOKEN}","role":"CorporateInterpreterRootAdmin"}

 

 

I need to extract the {TOKEN} value and be able to re-use it as a field in a later action step.

I tried a few output/return options, but I’m not sure how to do this.

 

Any ideas?

 

Thank you

Thomas

Best answer by robschmidt

Hi @Thomas2M 

You can use python for this (read Zapier python help docs on how to format your code) or you can use formatter>text>extract pattern and use a regex query to extract the token part. This should be more convenient to work with.

 

View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

robschmidt
Forum|alt.badge.img+9
  • Zapier Expert
  • 617 replies
  • Answer
  • November 22, 2021

Hi @Thomas2M 

You can use python for this (read Zapier python help docs on how to format your code) or you can use formatter>text>extract pattern and use a regex query to extract the token part. This should be more convenient to work with.

 


  • Author
  • Beginner
  • 7 replies
  • November 22, 2021

Hi @robschmidt,

Thank you for pointing me out in the right direction. The formatter with python regex did the trick.

In case this is helpful for the forum users, here’s the regex I used: (?<="token":").+(?=",)