I am working with Automation and web request action. The first step is below:
GET https://{site}/wiki/api/v2/pages?spaceid={spaceid}&title={title}&body-format=storage
I then store {{webResponse.body.results.body.storage.value}} in variable {{content}} and log it.
Next, I use below:
PUT https://{site}/wiki/api/v2/pages/{pageid}
{
"id": "{{webResponse.body.results.id}}",
"status": "current",
"title": "{{webResponse.body.results.title}}",
"body": { "representation": "storage", "value": "{{content}}" },
"version": { "number": {{#increment}}{{webResponse.body.results.version.number}}{{/}}, "message": "" }
}
There appears to be a problem with me passing back in {{content}}. Unfortunately, while this works if the page is super simple (just text), anything more complicated like elements or pictures causes the below:
UPDATE: I believe I found one of the problems! If the {{content}} contains any " without escaping them first, it just won't work. So to fix, I need to figure out a way to do a regex replacement.
UPDATE2: Use replace("\"", "\\\"") to fix the issue. Everything's working now, I could almost cry!
If {{content}} contains any " without escaping them first, it won't work. Use replace("\"", "\\\"") to fix the issue.
body-format=storage is XML. I would guess this isn't formatted correctly, and it is expecting a string and not XML.
"body": { "representation": "storage", "value":
If I have time later today I will attempt to reproduce what you are attempting, and see if I can help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you! I was pulling my hair out because this process seemed to work for everyone else. That's the thing though, even in the linked example, they passed it right back in without issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've updated my question, but it has to do with unescaped " in {{content}}. I need to set up regex replacement so that " are instead \".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are several regex generators on line, google and bookmark your favorite.
Or ask your favorite AI tool.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there anyway to do it in Automation? I tried {{content.replace(""","\"")}} but that didn't work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.