JSON-RPC updatePage

I've been having a lot of trouble trying to update a page via the remote API over the JSON-RPC protocol. I had this working with the SOAP method, but am trying to convert for the eventual upgrade to 4. Currently we are using 3.5.16, though.

Anyway, the request params are as follows:

[{
space:"SpaceName",
url: "https://site/display/SpaceName/Home",
version: 74,
creator: "me",
modified: 1359409259158,
content: "A whole lot of content in *wiki markup*",
modifier: "someone",
id: 1442917,
parentId: 0,
title: "Home",
created: 1304096018639,
contentStatus: "current",
current: true,
permissions: 0,
homePage: true
},
{
versionComment: "",
minorEdit: true
}]

The first is obviously the page, the second the Update Options. When I call the service, I receive the error, "Request parameter types did not match method parameter types (method updatePage taking 2 parameters)"

I've tried a whole lot of different things, and none have worked, so now I'm here. Please let me know if you have tried this before, or can see some obvious mistake I'm missing.

6 answers

1 accepted

Further update - the call structure above is correct but the updated page will loose the link to the parent page. To get correct behaviour correct it has to llo like this:

{"method":"storePage","jsonrpc":"2.0","params":{"id":25657372,"space":"ds","parentId":98334,"title":"test again","content":"Update from Java at 21.05.2013 11:28:36\u003cp\u003e","version":1}}

Some remarks to the json rpc call for storePage:

Regarding parentId: The documenttion states that parentId as a parameter is always optional. It should be pointed out that in case the parentId for page is set and the storePage for this page is called without the optional parameter the parentId is deleted!

Regarding version: If you do a getPage you will get a version - this version sould not be incremented by the storePage call but it needs to be the same - the increment will be done automatically by confluence. In case if you call storePage with another than the actual version number the call will be ignored!!! Btw. there should be at least an error message geiven back (this is not the case at them moment)

I have some example code in java in case somebody needs it...

Hmm, the way that you've done it seems to work, but only if I build up a JSON Object with only those fields. If I use the "getPage" object and just update it, then I sitll get errors, but if I build up a new custom object with those fields, it works.

Seems like there's something wrong there, but it's "working" now, so I'll give you credit for answering it.

Yes i agree that this is not at all according to documentation and the behaviour is very strange even though the call is working with the given parameters (but not with any additional parameters which according to documentation should be ignored) ...

Thanks Bob, but I have actually tried that as well. I still get the "non-matching types" issue. Am I missing something in my page structure?

Sorry, not sure what you are referring to. I use CLI to update my ondemand instance pages all the time. Page structure shouldn't matter.

Quick question -- are you using JSON-RPC, or SOAP? I have no problem when I used SOAP, as your CLI appears to, but as I mentioned, I'm trying to start using JSON.

What I meant by structure was the structure of the Page object. The API docs say a page must contain something like Space, Title, Content, and maybe something else (I am having difficulty connecting to the Docs pages at the moment).

CLI uses SOAP for this action.

That's unfortunate. Thanks for the idea, though.

Hi guys,

ran into the same issue as Graham - i managed succesfully to get a space and a page via JSON calls from confluence - all working fine. But when i try to update my page via storePage i get the error :"Request parameter types did not match method parameter types (method storeSpace taking 1 parameters). Now i passed my parameters as usually in a array called params which just has one element of type page:

{"params":{"id":25296900,"space":"DEPIT","parentId":10387460,"title":"TestPage","url":"http://xxx.xxx.xxx/display/DEPIT/TestPage","version":1,"content":"\u003cp\u003eTest for update\u003c/p\u003e\u003cp\u003eUpdate from Java2013-05-17 12:54:57","created":1368786366335,"modified":1368786366335,"modifier":"awirthmueller","homePage":false,"locks":0,"contentStatus":"current","current":true},"method":"storeSpace","id":25296900,"jsonrpc":"2.0"}

Anybody any idea what is going wrong?

Unfortunately, I still have no workaround for this. For the time being, I've been forced to use SOAP for this specific request.

Got a little step further - using this structure:

{"method":"storeSpace","jsonrpc":"2.0","params":{"id":25296900,"space":"DEPIT","title":"TestPage","content":"New content","version":1}}

the request passes - the structure is not according to documentation but seems to pass through (see also this issue: https://answers.atlassian.com/questions/55944/is-there-a-json-rpc-code-example-for-confluence).

Now i'm stuck as i get back a HTTP 200 OK - but a response with length "0" - no update happened. Will investigate further...

It is working now with the following structure for the json rpc call:

{"method":"storePage","jsonrpc":"2.0","params":{"id":25296900,"space":"DEPIT","title":"TestPage","content":"New content","version":1}}

Hey Martin. That looks useful, removes a lot of the overhead I don't really need. It doesn't seem to be *required,* though, at least not for the requests I'm making.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

778 views 23 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you