Hey everyone! I'm trying to figure out the correct formatting for the 'iCalText' value while creating or modifying door schedules using the OpenPath/Avigilon API. I regularly use this API for tasks like renaming and deleting accounts, but I'm getting stuck on this specific part. I'm using PowerShell's 'Invoke-WebRequest' POST method, and no matter what I try, I keep encountering an error saying the JSON format for the payload is invalid. I've attempted several variations of JSON along with hashtables, converting them to strings, and even tried plain text, but nothing works.
Here's an example of what I want to change (the date for Good Friday varies each year):
iCalText : BEGIN:VEVENT
DTSTART;TZID=America/New_York:20220919T000000
DTEND;TZID=America/New_York:20220919T235900
RRULE:FREQ=YEARLY;BYMONTH=4;BYMONTHDAY=18
X-OP-ENTRY-STATE:convenience
END:VEVENT
So, I'm looking for guidance on how to format this 'iCalText' correctly so that it can be accepted by the API. Any help or examples would be hugely appreciated!
1 Answer
I found a workable solution! Try formatting your payload like this:
$Day = "18"
$Body = "{`"iCalText`":`"BEGIN:VEVENTnDTSTART;TZID=America/New_York:20220919T000000nDTEND;TZID=America/New_York:20220919T235900nRRULE:FREQ=YEARLY;BYMONTH=4;BYMONTHDAY=$DaynX-OP-ENTRY-STATE:conveniencenEND:VEVENT`}"
# Update with Invoke-WebRequest
Make sure the `$Body` variable stays as a single line; breaking it into multiple lines can cause errors. I'm automating the door schedules for Good Friday based on this. Last year was chaotic because no one changed the date until I figured it out. Now it runs like a charm!
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String