I just installed Confluence 5.6.1 in order to use the new API endpoints for custom properties
https://docs.atlassian.com/atlassian-confluence/REST/latest/#d3e86
When I try to post a new property I am getting a 500 error
var req = new XMLHttpRequest(); req.open("GET", APIcall, false); req.send(null); console.log(req.responseText); var somejson = JSON.parse(req.responseText); console.log(somejson); //EVERYTHING WORKS GREAT UNTIL HERE jQuery.ajax({ contentType: 'application/json', type: 'POST', url: contextPath + "/rest/api/content/13238557/property", data: somejson, success: function(response) { console.log(response); } //And then BOOM! 500 error. API URL works great in my browser...
Besides this, I've tried various things in the REST API browser, all to no avail. Not sure what I am doing wrong
Thank you in advance!
This question is jumping off of this one right here
EDIT: This is my working solution for pulling saving JSON data with in a page. Thank you for the help everyone.
<script type="text/javascript"> var APIcall="http://apicallthatreturnssomejson.com"; var request = new XMLHttpRequest(); request.open("GET", APIcall, false); request.send(null); console.log(request.responseText); var response = JSON.parse(request.responseText); jQuery.ajax({ contentType: 'application/json', type: 'POST', url: contextPath + "/rest/api/content/" + $content.id + "/property", data: JSON.stringify({key:"mykey", value:response}), processData: false, success: function(postresponse) { console.log(postresponse); } });
Community moderators have prevented the ability to post new answers.
Hi Neil, have you tried to send this REST call using curl to eliminate variables and see if it works? I've just tested it using the example JSON and it worked here:
$ curl -D- -u admin:admin -X POST --data "{\"key\":\"example-property-key\",\"value\":{\"anything\":\"goes\"},\"content\":{\"id\":\"360456\",\"type\":\"page\",\"_links\":{\"self\":\"http://192.168.10.224:8561/rest/api/content/360456\"},\"_expandable\":{\"body\":\"\",\"container\":\"\",\"ancestors\":\"\",\"children\":\"\",\"descendants\":\"\",\"metadata\":\"\"}},\"version\":{\"number\":2,\"minorEdit\":false},\"_links\":{\"base\":\"http://192.168.10.224:8561\",\"context\":\"\",\"self\":\"http://192.168.10.224:8561/rest/api/content/360456/property/example-property-key\"}}" -H "Content-Type: application/json" http://192.168.10.224:8561/rest/api/content/360456/property HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-ASEN: SEN-L3897800 Set-Cookie: JSESSIONID=CF1289EE83FD4FBD3772C34DEB65CB9D; Path=/; HttpOnly X-Seraph-LoginReason: OK X-AUSERNAME: admin X-Content-Type-Options: nosniff Content-Type: application/json Transfer-Encoding: chunked Date: Tue, 09 Sep 2014 14:04:24 GMT {"id":"360457","key":"example-property-key","value":{"anything":"goes"},"version":{"when":"2014-09-09T11:04:24.136-0300","message":"","number":1,"minorEdit":false},"_links":{"base":"http://192.168.10.224:8561","context":"","self":"http://192.168.10.224:8561/rest/api/content/360456/property/example-property-key"},"_expandable":{"content":"/rest/api/content/360456"}}
Cheers
OK! That worked! Now... what is all that other stuff in the data object? (_links, _self, _expandable etc) At least some of it is clearly necessary. Is it that documented somewhere that I missed?
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.
Please take we off all the mailing lists! I'm getting atlassian emails starting the last few days!
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.