Creating Wiki Page With API Does Not Link Parent_ID

37 views
Skip to first unread message

Ross McMahon

unread,
Jan 15, 2016, 9:51:47 AM1/15/16
to Assembla API Development
Hello, first time post so apologies for any mistakes.

I have set up a quick script to loop through some services to provide a function reference in a project wiki.

I can get pages set up no problem, but it seems that when I specify parent_id, although the ID is correct, the page created is always created at the root of the wiki, not as a child of the parent specified.

Is there some other parameter I need to include, or something else I am missing for this to happen?

The JSON payload looks like so:

wiki_page : {
    page_name : pageName.length > 50 ? pageNameAt50 : pageName,
    contents : "",
    parent_id : parentID
}

As mentioned, the page is created no problem, but not as a child of the parent specified.

Any advice welcome.

Ross

Stanislav Kolotinskiy

unread,
Jan 25, 2016, 11:31:12 AM1/25/16
to assembla...@googlegroups.com
Hi Ross,

I just checked out wiki pages creation with a parent, and it worked fine for me. Could you please post the actual snippet of code that performs the request?

Regards,
Stanislav
--
You received this message because you are subscribed to the Google Groups "Assembla API Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to assembla-api-d...@googlegroups.com.
To post to this group, send email to assembla...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ross McMahon

unread,
Jan 26, 2016, 5:15:00 AM1/26/16
to Assembla API Development
Hi, sure.

I'm using CFML as the language:

<cffunction name="createWikiPage" output="false" access="public" hint="">
<cfargument name = "assemblaSpaceName" type = "string" required = true />
<cfargument name = "pageName" type = "string" required = true />
<cfargument name = "parentID" type = "string" required = true />
<cfargument name = "content" type = "string" required = true default="" />

<cfset var result={message="Cannot create wiki page",status="FALSE",data={}} />
<cfset var data = ""/>
<cfset apiurl = "#GetAssemblaBaseURL()##arguments.assemblaSpaceName#/wiki_pages.json"/>

<!--- create the page using a JSON string --->
<cfset var data = {
wiki_page = {
page_name = len(arguments.pageName) gt 50 ? ReplaceNoCase(arguments.pageName, " ", "", "all") : arguments.pageName,
contents = "",
parent_id = arguments.parentID,
content = arguments.content
}
} />
<cfset data = lCase(serializeJSON(data))>

<!--- Call the web Service --->
<cfhttp url="#apiUrl#" method="post" result="returnData" >
<cfhttpparam name="X-API-Key" type="header" value="#GetAssemblaAPIKey()#">
<cfhttpparam name="X-API-Secret" type="header" value="#GetAssemblaAPISecret()#">
<cfhttpparam name="Content-type" type="header" value="application/json">
<cfhttpparam name="wiki_page" type="body" value="#data#">
</cfhttp>

<cfif returnData.statusCode contains "201">
<cfset result.message="OK"/>
<cfset result.status="True"/>
</cfif>

<cfset result.data = returnData.filecontent />

<cfreturn result />
</cffunction>

Happy to explain any of it if you require it! 

Just to recap: pages are being created, and when I receive the response they ostensibly have a parent_id, but if I look in the wiki, they're only children of the root.

A second question would be: how on earth do you find the IDs of Wiki pages? At the moment I'm having to go into the 'edit' page of a page and then inspect the select element for parent using devtools.

Thanks,
Ross
Reply all
Reply to author
Forward
0 new messages