Best answer

Using a dynamic key in POST request - possible? (Updating Sportspress event in Wordpress)

  • 5 December 2023
  • 2 replies
  • 66 views

Hey folks, hope you’re doing well! Been stepping up my Zapier automation game lately and been working on a project that essentially triggers when a spreadsheet is updated with sports event scores and automatically updates a Sportspress event hosted on a Wordpress website.

 

I’m so close I can almost taste it!

 

Everything works well until I need to make a dynamic reference to the two teams participating in the games. Essentially I am using a POST request through Zapier App Extensions and I can get everything to update as desired when I have hardcoded team ID numbers. But when I try to reference these variables {{home_id}} and {{away_id}} it seems to read these characters literally instead of recognizing that it should be a variable.

 

If I use the actual IDs of these teams, everything works as intended. The challenge presents itself when I try to use these variables as it’s reading the variables literally.

 

I’m attaching some screenshots so you can take a peek and if more information is required I will edit this post accordingly. Any insight into this would be appreciated! I’ve spent a couple days working on this specific project so far and prepared to spend many more, but I seem to be hitting a roadblock with this variable referencing issue and can’t find many tutorials that are specific enough to this issue that would be helpful. If anyone knows of some valuable resources where I can learn more about this I would really appreciate that too!

 

 

Here’s the full pasted data as well for the Zapier output if it’s helpful.

 

request

method

POST

url

https://westernballhockey.com/wp-json/sportspress/v2/events/17981

querystring

headers

Content-Type

application/json

body

No data to show for this record

data

results

0

goals

Final

{{home_id}}

goals

987

outcome

1

Win

{{away_id}}

goals

654

outcome

1

Loss

response

status

200

headers

body

{"id":17981,"date":"2023-09-13T19:00:00","date_gmt":"2023-09-14T01:00:00","guid":{"rendered":":censored:29:d865de9b0b:/?post_type=sp_event&p=17981","raw":":censored:29:d865de9b0b:/?post_type=sp_event&p=17981"},"modified":"2023-12-05T13:17:22","modified_gmt":"2023-12-05T20:17:22","password":"","slug":"17981","status":"publish","type":"sp_event","link":":censored:29:d865de9b0b:/archives/event/17981","title":{"raw":"Muffin Men vs Money Mafia","rendered":"Muffin Men vs Money Mafia"},"content":{"raw":"","rendered":"","protected":false,"block_version":0},"excerpt":{"raw":"","rendered":"","protected":false},"author":1,"featured_media":0,"template":"","format":"league","leagues":[200],"seasons":[224],"venues":[17],"permalink_template":":censored:29:d865de9b0b:/archives/event/%pagename%","generated_slug":"muffin-men-vs-money-mafia","teams":[16241,16240],"mode":"","day":"","minutes":"90","players":[0,0],"offense":[],"defense":[],"staff":[],"results":{"0":{"first":"1st","second":"2nd","third":"3rd","ot":"OT","ppg":"PPG","ppo":"PPO","goals":"Final","outcome":"Outcome"},"16240":{"first":"","second":"","third":"","ot":"","ppg":"","ppo":"","goals":"654","outcome":["Loss"]},"16241":{"first":"","second":"","third":"","ot":"","ppg":"","ppo":"","goals":"987","outcome":["Win"]}},"performance":[{"position":"Position","gamesplayed":"GP","g":"G","a":"A","p":"P","h":"H","pim":"PIM","s":"SOG","sa":"SA","ga":"GA","sv":"SV"}],"_links":{"self":[{"href":":censored:29:d865de9b0b:/wp-json/wp/v2/events/17981"}],"collection":[{"href":":censored:29:d865de9b0b:/wp-json/wp/v2/events"}],"about":[{"href":":censored:29:d865de9b0b:/wp-json/wp/v2/types/sp_event"}],"author":[{"embeddable":true,"href":":censored:29:d865de9b0b:/wp-json/wp/v2/users/1"}],"wp:attachment":[{"href":":censored:29:d865de9b0b:/wp-json/wp/v2/media?parent=17981"}],"wp:term":[{"taxonomy":"sp_league","embeddable":true,"href":":censored:29:d865de9b0b:/wp-json/wp/v2/leagues?post=17981"},{"taxonomy":"sp_season","embeddable":true,"href":":censored:29:d865de9b0b:/wp-json/wp/v2/seasons?post=17981"},{"taxonomy":"sp_venue","embeddable":true,"href":":censored:29:d865de9b0b:/wp-json/wp/v2/venues?post=17981"}],"wp:action-publish":[{"href":":censored:29:d865de9b0b:/wp-json/wp/v2/events/17981"}],"wp:action-unfiltered-html":[{"href":":censored:29:d865de9b0b:/wp-json/wp/v2/events/17981"}],"wp:action-assign-author":[{"href":":censored:29:d865de9b0b:/wp-json/wp/v2/events/17981"}],"wp:action-create-leagues":[{"href":":censored:29:d865de9b0b:/wp-json/wp/v2/events/17981"}],"wp:action-assign-leagues":[{"href":":censored:29:d865de9b0b:/wp-json/wp/v2/events/17981"}],"wp:action-create-seasons":[{"href":":censored:29:d865de9b0b:/wp-json/wp/v2/events/17981"}],"wp:action-assign-seasons":[{"href":":censored:29:d865de9b0b:/wp-json/wp/v2/events/17981"}],"wp:action-create-venues":[{"href":":censored:29:d865de9b0b:/wp-json/wp/v2/events/17981"}],"wp:action-assign-venues":[{"href":":censored:29:d865de9b0b:/wp-json/wp/v2/events/17981"}],"curies":[{"name":"wp","href":"https://api.w.org/{rel}","templated":true}]}}

data

id

17981

date

2023-09-13T19:00:00

date_gmt

2023-09-14T01:00:00

guid

rendered

:censored:29:d865de9b0b:/?post_type=sp_event&p=17981

raw

:censored:29:d865de9b0b:/?post_type=sp_event&p=17981

modified

2023-12-05T13:17:22

modified_gmt

2023-12-05T20:17:22

password

slug

17981

status

publish

type

sp_event

link

:censored:29:d865de9b0b:/archives/event/17981

title

raw

Muffin Men vs Money Mafia

rendered

Muffin Men vs Money Mafia

content

raw

rendered

protected

false

block_version

0

excerpt

raw

rendered

protected

false

author

1

featured_media

0

template

format

league

leagues

1

200

seasons

1

224

venues

1

17

permalink_template

:censored:29:d865de9b0b:/archives/event/%pagename%

generated_slug

muffin-men-vs-money-mafia

teams

1

16241

2

16240

mode

day

minutes

90

players

1

0

2

0

offense

defense

staff

results

0

first

1st

second

2nd

third

3rd

ot

OT

ppg

PPG

ppo

PPO

goals

Final

outcome

Outcome

16240

first

second

third

ot

ppg

ppo

goals

654

outcome

1

Loss

16241

first

second

third

ot

ppg

ppo

goals

987

outcome

1

Win

performance

1

position

Position

gamesplayed

GP

g

G

a

A

p

P

h

H

pim

PIM

s

SOG

sa

SA

ga

GA

sv

SV

_links

self

1

href

:censored:29:d865de9b0b:/wp-json/wp/v2/events/17981

collection

1

href

:censored:29:d865de9b0b:/wp-json/wp/v2/events

about

1

href

:censored:29:d865de9b0b:/wp-json/wp/v2/types/sp_event

author

1

embeddable

true

href

:censored:29:d865de9b0b:/wp-json/wp/v2/users/1

wp:attachment

1

href

:censored:29:d865de9b0b:/wp-json/wp/v2/media?parent=17981

wp:term

1

taxonomy

sp_league

embeddable

true

href

:censored:29:d865de9b0b:/wp-json/wp/v2/leagues?post=17981

2

taxonomy

sp_season

embeddable

true

href

:censored:29:d865de9b0b:/wp-json/wp/v2/seasons?post=17981

3

taxonomy

sp_venue

embeddable

true

href

:censored:29:d865de9b0b:/wp-json/wp/v2/venues?post=17981

wp:action-publish

1

href

:censored:29:d865de9b0b:/wp-json/wp/v2/events/17981

wp:action-unfiltered-html

1

href

:censored:29:d865de9b0b:/wp-json/wp/v2/events/17981

wp:action-assign-author

1

href

:censored:29:d865de9b0b:/wp-json/wp/v2/events/17981

wp:action-create-leagues

1

href

:censored:29:d865de9b0b:/wp-json/wp/v2/events/17981

wp:action-assign-leagues

1

href

:censored:29:d865de9b0b:/wp-json/wp/v2/events/17981

wp:action-create-seasons

1

href

:censored:29:d865de9b0b:/wp-json/wp/v2/events/17981

wp:action-assign-seasons

1

href

:censored:29:d865de9b0b:/wp-json/wp/v2/events/17981

wp:action-create-venues

1

href

:censored:29:d865de9b0b:/wp-json/wp/v2/events/17981

wp:action-assign-venues

1

href

:censored:29:d865de9b0b:/wp-json/wp/v2/events/17981

curies

1

name

wp

href

https://api.w.org/{rel}

templated

true

icon

Best answer by Troy Tessalone 5 December 2023, 21:30

View original

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

Userlevel 7
Badge +14

Hi @mhallet 

Good question.

Perhaps try this Zap action: WordPress - API Request

Similar to the App Extension, but gives you a bit more control to configure.

 

Thanks! I was able to make it work with your recommendation. I appreciate your quick and accurate response!