Skip to main content
Best answer

How to use Python to extract value from unparsed webhook payload?


I would like to create a python regular expression that will search through an unparsed webhook:

{"Opportunity":{"Client Name" :"Mike DevTest","Client Email":"sample@gmail.com","Primary Contact":"Mike DevTest","Event Start Date/Time" : "12/24/2021 4:00 AM","Event End Time":"6:30 PM","Event Location":"Houston","Event Type":"Wedding","State" : "TX","Venue" : "Virtual Chicago","Additional Musicians" : "false","Cocktail Music" : "true","Dinner Music" : "true","Grand Piano Shells" : "false","uplights" : "false","mini piano shells" : "false","projector" : "false","Wedding Ceremony" : "false","Evening Entertainment" : "true","DJ Services" : "true","Type Of Ensemble" : "Dueling Pianos","Primary Owner Email":"sample@gmail.com","Primary Owner Mobile":"(555) 555-555","Salesforce Id":"0068F000002G5quQAC","Added To PIP":"true","Date added to PIP":"3/1/2022","Amount":"1700.00","Performers":"2","Lead Photographer":"true","2nd Photographer":"true","Lead Videographer":"false","2nd Videographer":"false","Client Time Zone":"MT","Studio Time Zone":"ET","Studio Start Time":"12:30 AM","Studio End Time":"1:30 AM","Inbound or Generated":"Generated","Piano Man":"true","Rocket Man":"true","Great Balls of Fire":"true","Main Service Interested In":"Photo"}}

I want it to return the value for the “Salesforce Id”, which would be 0068F000002G5quQAC

Can someone help me with that regular expression?

Best answer by Troy TessaloneBest answer by Troy Tessalone

Hi @gregp 

Try this JavaScript Code step:

 

 

 

let RAW = inputData.RAW
let SFID = RAW.split('"Salesforce Id":"')[1].split('"')[0];

output = [{SFID, RAW}];

 

NOTE: This doesn’t use REGEX, rather it uses 2 split methods to isolate the desired value.

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.

4 replies

Troy Tessalone
Forum|alt.badge.img+14
  • Zapier Expert
  • 30996 replies
  • Answer
  • March 2, 2022

Hi @gregp 

Try this JavaScript Code step:

 

 

 

let RAW = inputData.RAW
let SFID = RAW.split('"Salesforce Id":"')[1].split('"')[0];

output = [{SFID, RAW}];

 

NOTE: This doesn’t use REGEX, rather it uses 2 split methods to isolate the desired value.


  • Author
  • New
  • 2 replies
  • March 2, 2022

@Troy Tessalone I appreciate your help very much!

Not sure if I did this right, but it is giving me a syntax error.

 

 


Troy Tessalone
Forum|alt.badge.img+14

@gregp 

This is JavaScript, so you’ll need to use the JavaScript Code step.


  • Author
  • New
  • 2 replies
  • March 2, 2022

@Troy Tessalone Yes, you clearly said that the first time and somehow my brain managed to not pick up on it.  ;) Thank you very much!  The javascript solution works perfectly!