0

I haven't used REST services in combination with JSON-RPC that much, so I could use some help here.

I am trying to add an attachment to a page in Confluence using a JSON-RPC call. I am testing my calls using soapUI 5.0.0.

The URI of my REST call is:

https://{sitename}/rpc/json-rpc/confluenceservice-v2/addAttachment

I have constructed the following JSON code, which should create a very simple text file:

[ 2339970
, { "fileName" : "Testfile.txt"
  , "contentType" : "text/plain"
  , "comment" : "to be ignored"
  }
, "VGhpcyBpcyBhIHRlc3QuClRvIENvbmZsdWVuY2Ugb3Igbm90IHRvIENvbmZsdWVuY2U/Cg=="
]

The third parameter is a base64 encoded string.

Unfortunately I get an error message from the server:

<error>
   <code>-32602</code>
   <data null="true"/>
   <message>Request parameter types did not match method parameter types (method addAttachment taking 3 parameters)</message>
</error>

Any idea what I'm doing wrong here?

Crow74
  • 51
  • 1
  • 7
  • I think you are confused. A service cannot be simultaneously a REST and a JSON-RPC endpoint. JSON-RPC over HTTP is pretty much always going to be a POST (GET is possible, but rare). It must have a valid JSON-RPC envelope. You've show JSON that *might* possibly work as the `params` property of the envelope, but nont of the rest. That fact that you've shown an XML error message leans me to belive that either this is a frankenservice, or this has nothing at all to do with JSON-RPC. – David-SkyMesh May 21 '14 at 06:26
  • I should clarify the prior comment. A service *can* provide both REST and JSON-RPC endpoints, but you can't send a REST *request* to a JSON-RPC *endpoint* -- JSON-RPC expects the message body to be an non-encoded (raw) JSON string which is serialized from a very specific set of elements (the "envelope"). The URL you give looks very much like a REST endpoint. What makes you think that this has anything at all to do with JSON-RPC? Just because you PUT/POST some JSON (and perhaps get JSON in the body of your reply) *does not make it JSON-RPC*; that's an entirely different protocol. – David-SkyMesh May 22 '14 at 00:38
  • @David-SkyMesh: Thank you so much for your comments. I got indeed confused and you cleared that up perfectly. I also realized that the path I am following using JSON-RPC calls is not the road I wanted to follow in the first place, so I will abandon this path. – Crow74 May 26 '14 at 08:28

0 Answers0