how to use rest api to create extension api on Bonita BPM - bonita

I have one extension api, I upload it form web/resource/REST API, affter upload, it works well. however, I used the code to upload, i used the PageAPI.createPage() to upload extension, it upload success, but it doesn' work, I check the file on server, from the server, I can't find the extension from the ${BONITA_HOME}\bonita\client\tenants\1\work, it only exist on ${BONITA_HOME}\bonita\client\tenants\1\temp, debug, the files is invode the pageAPI servlet, and invode the PageDataStore.createEngieenPage(), so my question is how can i use the REST API to add extension and deploy it?

In order to deploy a Bonita REST API extension programmatically you need to:
Call the loginservice REST API for authentication
Send the file to a temporary folder on server side using the uploadPage servlet
Register the new REST API extension by calling the portal/page REST API
I create a basic Groovy script that demonstrate that.

Related

How to setup api,s in react native template

I have a react native app (chat) template which I cant figure out how to set it up, don't know if am to get an api key from cometchat or use firebase. The template has been preconfigured I think and by adding firebase credential in the env. the login and register page works, but the chat section is blank.
This is what the documentation says:[
API Integration
Doot react having fake-backend setup already. you will find all files related to API integrations in the src/API folder.
src/apiCore.ts file contains axios setup to call server API(s) including get, put, post, patch, delete, etc methods, interceptors & token set methods.
src/index.ts file contain all module's API call functions which are exported from each module's individual .ts file, E.g. contacts.ts, bookmarks.ts etc.
src/urls.ts file contain all module's API's url.
Note : we have added a Fake backend setup just for user interactions, but if you are working with the real API integration, then there is no need of fake backend as well as the fakeBackend file located in src/helpers/fakeBackend.ts, so you can delete it and also remove the code related to fakeBackend from app.tsx file. you just need to update API's url of the related module from src/apiCore/urls file, that's it!}
The chat interface after login:
App documentation:
App documentation:

File upload in Directus

So i'm trying to upload pdf files to directus. In postman it's working fine and uploads successfully on my React project i keep getting "You are not allowed to upload files. What am I doing wrong?
Could be cors problem
Could be that you overwrite your token via postman
From the official Directus API Docs:
By default, all data in the system is off limits for unauthenticated users. To gain access to protected data, you must include an access token with every request.
Source: https://docs.directus.io/api/authentication.html
I don't know how your project is structured, but if you're already authenticated within your (Web)app and want to upload using Axios or similar, you should pass the temporary or static token that you've already got to the library or method that sends the file (Header -> Authorization: bearer xxtokenxx).
If you still have questions, the documentation link above has everything you need.

How to consume external API with server side in ReactJs in one project?

I want to consume an API of a company, and this API could not be consumed with a Client Side Script such as Javascript, I want to use react js to consume this API on the Server Side but on the same project.
I asked the owner of the API and I receive an email :
It is not possible to use our API request in a client-side language script such as Javascript, it must be used in a server-side script.
How can I do that ?
Thanks !
As far as I know, you have to options:
create an API that works as a proxy and this API calls the other API (so, the proxy-api is called by client/react and the second API is just called by the proxy-api
use server side render in react (you can see more about this alternative in: https://www.digitalocean.com/community/tutorials/react-server-side-rendering)

Sending files to Kloudless saver from clientside

I'm currently using a dropbox client js script to push zip files to a folder (in test, a couple of k, in production, a couple of hundred meg) - there currently isn't a server/back end, so am posting from an arraybuffer, not a server url.
var zip = new JSZip();
zip.file("test.txt", "Hello World\n");
var content = zip.generate({type:"arraybuffer"});
// ... code to pick a dropbox folder ...//
client.writeFile(url+"/"+fileName, content, function(error){ ... etc
This all works fine - client is able to write the binary file (which Dropbox's own Saver is unfortunately unable to do). I'm trying to see if Kloudless is able to perform the same, since I also need to support google, box, etc at some point. https://github.com/kloudless/file-explorer/'s documentation about its saver says the files are an array of urls ..
explorer({
...
files: [{
"url": "http://<your image url>",
"name": "filename.extension"
},
It doesn't seem to like local storage file references using URL.createObjectURL(blob), so I'm guessing the api is telling the remote services to pull the files rather than pushing their data.
You are correct that the Kloudless API backend servers stream the file from the URL to the final destination in whichever cloud service you would like the file to be uploaded to (e.g. a folder in a Dropbox account).
If the files are present only on the client-side, I would recommend using the Kloudless Chooser to instead prompt the user to choose a folder to save the files in, and then handle uploading the file data to that destination via the client-side manually.
To do this, refer to this example configuration: https://jsfiddle.net/PB565/139/embedded/
I have set retrieve_tokens to true so that my client-side JavaScript will receive not just the metadata of the folder the user chooses to upload the data to but also the Bearer token to use to gain access to the user's account. This allows the client-side JavaScript to then make upload or multipart upload requests to Kloudless to upload the file data to that folder. The advantage of multipart uploads is that an error uploading one chunk wouldn't require the whole upload to be retried.
Be sure to add the domain you are hosting the File Explorer on to your Kloudless App's Trusted Domains (on the App Details page) so that it can in fact receive the Bearer token in the response JS callback. In my JSFiddle example, I would have to add 'fiddle.jshell.net' to my app's list of Trusted Domains to be able to receive the Bearer token to perform further requests from the client side to the Kloudless API.

AngularJS CSV File Download from API

I have an admin control panel where admin users can set a few options and then click a button to run a report. The report should return a CSV file download prompt to the user.
I am using ui-router and $resource services. The response headers/mime type are set correctly, but the CSV file is returned as text (no file download initiated) by the $resource handler.
I tried creating the download link directly, by forming a querystring from the $scope, but unfortunately my API's authentication scheme uses a custom HTTP header token and it's not possible to send that to the API (which is also on another subdomain) via an anchor tag, such as this one:
Run
Is there a way to initiate a file download prompt using an XHR request (with custom header)?
I'm using a custom header token so downloading the report via a simple link is impossible; the request has to be made via XHR. My two-part solution:
Returned the CSV data from the API directly as text, removing file attachment headers. This is the correct solution, anyway, because it keeps the REST JSON API unconcerned with file downloads, which are a browser concept.
Wrapped the API response data in a Blob, and then used https://github.com/eligrey/FileSaver.js to initiate a file download.
A drawback is this requires IE10+, but that is okay in my case.

Resources