2
2
Fork
You've already forked api-scripts
3

Book ID? #7

Closed
opened 2023年05月02日 13:01:04 +02:00 by Maltavius · 4 comments
Maltavius commented 2023年05月02日 13:01:04 +02:00 (Migrated from github.com)
Copy link

I'm trying to run the Powershell Import HTML-script but I don't have a number that is a book ID.
I cannot seem to find where the ID is present in the GUI of the application. I tried the name of the book as it's written in the URL but that didn't work.

I'm trying to run the Powershell Import HTML-script but I don't have a number that is a book ID. I cannot seem to find where the ID is present in the GUI of the application. I tried the name of the book as it's written in the URL but that didn't work.
ssddanbrown commented 2023年05月02日 13:06:24 +02:00 (Migrated from github.com)
Copy link

@Maltavius It's not something that's specifically exposed in the UI.
You can get IDs using the /api/books endpoint (You can go to that end point in your browser, while logged in as an API-allowed user, since it's just a GET request).

Alternatively, and less officially, you could paste the following into the browser developer console while viewing a book within the interface:

document.querySelector('[option\\:entity-search\\:entity-type="book"]').getAttribute('option:entity-search:entity-id') 
@Maltavius It's not something that's specifically exposed in the UI. You can get IDs using the `/api/books` endpoint (You can go to that end point in your browser, while logged in as an API-allowed user, since it's just a GET request). Alternatively, and less officially, you could paste the following into the browser developer console while viewing a book within the interface: ```javascript document.querySelector('[option\\:entity-search\\:entity-type="book"]').getAttribute('option:entity-search:entity-id') ```
Maltavius commented 2023年05月02日 13:20:37 +02:00 (Migrated from github.com)
Copy link

Thanks, yes I did figure that out myself. /api/books/ helped,

But now I get

Create-BookstackPage : Cannot process argument transformation on parameter 'Html'. Cannot convert value to type System.String.
At D:\Temp\woxwox\Test\powershell\files-to-pages.ps1:54 char:37
+ Create-BookStackPage $file.Name $fileContent $parentBookId
+ ~~~~~~~~~~~~
 + CategoryInfo : InvalidData: (:) [Create-BookstackPage], ParameterBindingArgumentTransformationException
 + FullyQualifiedErrorId : ParameterArgumentTransformationError,Create-BookstackPage
Thanks, yes I did figure that out myself. /api/books/ helped, But now I get ``` Create-BookstackPage : Cannot process argument transformation on parameter 'Html'. Cannot convert value to type System.String. At D:\Temp\woxwox\Test\powershell\files-to-pages.ps1:54 char:37 + Create-BookStackPage $file.Name $fileContent $parentBookId + ~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Create-BookstackPage], ParameterBindingArgumentTransformationException + FullyQualifiedErrorId : ParameterArgumentTransformationError,Create-BookstackPage ```
ssddanbrown commented 2023年05月02日 13:28:38 +02:00 (Migrated from github.com)
Copy link

Not sure about that.

You could maybe try adding the -Raw flag to the previous Get-Content call. Might be the case that I tested on single-line HTML files but PowerShell treats multi-line as an array of some kind.

My knowledge of Powershell is very limited, and keep in mind I wrote this using PowerShell (Core) 7.2.10 on Linux.
As listed in the readme, there is this project which provides a more extensive PowerShell API project.

Not sure about that. You could maybe try adding the `-Raw` flag to the previous [`Get-Content` call](https://github.com/BookStackApp/api-scripts/blob/577f44efee427e4ab003c918ade591dbd1e84f82/powershell-files-to-pages/files-to-pages.ps1#L53). Might be the case that I tested on single-line HTML files but PowerShell treats multi-line as an array of some kind. My knowledge of Powershell is very limited, and keep in mind I wrote this using PowerShell (Core) 7.2.10 on Linux. As listed in the readme, there is [this project](https://github.com/My-Random-Thoughts/psBookStack) which provides a more extensive PowerShell API project.
Maltavius commented 2023年05月02日 13:32:25 +02:00 (Migrated from github.com)
Copy link

OK, most of my 800+ HTML-files are 1000+ (Biggest file is 10090) lines exported from Confluence. I need a way to import all of the Confluence Data into BookStack to be able to evaluate it properly, I thought this script might be it.

OK, most of my 800+ HTML-files are 1000+ (Biggest file is 10090) lines exported from Confluence. I need a way to import all of the Confluence Data into BookStack to be able to evaluate it properly, I thought this script might be it.
Sign in to join this conversation.
No Branch/Tag specified
main
No results found.
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bookstack/api-scripts#7
Reference in a new issue
bookstack/api-scripts
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?