Using Webscript to post Topic to Forum Content Type
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2009 11:50 AM
All -
I am attempting to develop a little javascript application that will allow me to post a topic to a discussion forum for a content item. In doing this, I am trying to use the /alfresco/service/api/forum/node/{store_type}/{store_id}/{id}/posts webscript that is installed with Alfresco.
Here is my code (removed the callback for brevity here):
However, I'm having some trouble getting this to work. I continue to get an error that looks like this:
I suspect that the problem is related to the way I am posting my content, but I can't find the "right" way to do this. Does anyone have a quick working example that could point me in the right direction?
Thanks in Advance,
Russell
I am attempting to develop a little javascript application that will allow me to post a topic to a discussion forum for a content item. In doing this, I am trying to use the /alfresco/service/api/forum/node/{store_type}/{store_id}/{id}/posts webscript that is installed with Alfresco.
Here is my code (removed the callback for brevity here):
var sUrl = "/alfresco/service/api/forum/node/workspace/SpacesStore/c128f4c1-22f2-4d74-a924-a6a2dcf731fd/posts";var data = '{"title": "This is the title", "content": "This is my post content"}';var postData = YAHOO.lang.JSON.stringify(data);var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
However, I'm having some trouble getting this to work. I continue to get an error that looks like this:
"status" : { "code" : 500, "name" : "Internal Error", "description" : "An error inside the HTTP server which prevented it from fulfilling the request." }, "message" : "09261343 Wrapped Exception (with status template): 09261342 Error during processing of the template 'Error executing macro: postJSON\nrequired parameter: postData is not specified.'. Please contact your system administrator.", "exception" : "org.alfresco.web.scripts.WebScriptException - 09261343 Wrapped Exception (with status template): 09261342 Error during processing of the template 'Error executing macro: postJSON\nrequired parameter: postData is not specified.'. Please contact your system administrator.", "callstack" : [ "" ,"freemarker.template.TemplateException: Error executing macro: postJSON\nrequired parameter: postData is not specified." …
I suspect that the problem is related to the way I am posting my content, but I can't find the "right" way to do this. Does anyone have a quick working example that could point me in the right direction?
Thanks in Advance,
Russell
Labels:
- Labels:
-
Archive
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2009 11:15 PM
Russell,
I suspect the problem is that you aren't setting your mime type in the header to "application/json". Alfresco handles JSON posts in a special way so if the incoming request isn't identified as JSON, the web script probably isn't snagging your data at all.
I used curl to post your json without the mime type set and got your error. Once I set the mime type it posted successfully.
Jeff
I suspect the problem is that you aren't setting your mime type in the header to "application/json". Alfresco handles JSON posts in a special way so if the incoming request isn't identified as JSON, the web script probably isn't snagging your data at all.
I used curl to post your json without the mime type set and got your error. Once I set the mime type it posted successfully.
curl -v -X POST "http://localhost:8080/alfreso/service/api/forum/node/workspace/SpacesStore/fbd4e50e-04e7-4e52-8280-9..." -H "Content-Type: application/json" -d @/Users/jpotts/tmp.json
Can you try again but this time, include the following line just before your post:YAHOO.util.Connect.initHeader("Content-Type", "application/json");
Hope that helps,Jeff