Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JSON-RPC updatePage

Graham Mueller January 29, 2013

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

1 vote
Answer accepted
Andreas Wirthmueller May 20, 2013

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...

Graham Mueller May 22, 2013

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.

Andreas Wirthmueller May 22, 2013

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) ...

0 votes
MartinS
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 13, 2014

Note to self: when using the REST-API-Browser, you have to use the "Light Protocol": https://developer.atlassian.com/display/CONFDEV/Confluence+JSON-RPC+APIs#ConfluenceJSON-RPCAPIs-TheLightProtocol

Graham Mueller May 14, 2014

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.

0 votes
Andreas Wirthmueller May 20, 2013

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}}

0 votes
Andreas Wirthmueller May 20, 2013

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...

0 votes
Andreas Wirthmueller May 16, 2013

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?

Graham Mueller May 16, 2013

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

0 votes
Bob Swift
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2013

storePage action from Confluence Command Line Interface would do this easily.

Graham Mueller February 3, 2013
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?
Bob Swift
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 3, 2013

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.

Graham Mueller February 3, 2013

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).

Bob Swift
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 3, 2013

CLI uses SOAP for this action.

Graham Mueller February 3, 2013

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events