Running a Notebook via its REST API
The platform's Notebook engine offers a REST API allowing you to invoke a Notebook giving it parameters and getting the result of its run.
For instance, in this example application, I'm invoking the Notebook with 2DSQMTC7Z and I'm sending the parameter ICN:
To invoke a Notebook using the REST API, you can follow these steps:
- Firstly, access your Notebook to see the identifier. You can see it in the URL; in this example, 2DTG1H1S5
- Then, access the Swagger console of the platform instance you are using. In this case, https://www.onesaitplatform.online/controlpanel/swagger-ui.html
In the upper section, select notebook-ops:
- Unfold the service options and you will see:
- In this case, you want to run all the paragraphs in your Notebook, synchronously, so you will select the second method.
As parameters, select the Notebook's Id and the BearerToken, which you will take from:
This is the running:
- The given result will be OK:
- Go back to the Notebook and get the last paragraph's identifier, to ask for the result:
- Then run the first method with these parameters:
The result is a message like the following one. In this specific case, the last paragraph returned an image, so here I'm returned an HTML with the image formatted in Base64 on a div so that I can embed it in my website: