Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

With Bimplus account you obtain also unique application id for your application. If you don't have application id, please contact Allplan company to get one.

 


Please note that currently we have dev, stage, prod API servers and each of these uses separate accounts. It's not possible to use dev credentials to login into our prod or stage servers. Application id is the same for all api servers, so you can use the same for all our api servers.

...

import BimWebSdk from 'bimplus-websdk';

// cache - flag if Bimplus WebSdk should use internal indexeddb cache to store all requests - Dexie plugin is required if it's turned on
// host - choose api server for connection, currently we have these servers - api-dev.bimplus.net, api-stage.bimplus.net, api.bimplus.net
// protocol - choose protocol - http or https
var apiConfig ={    cache: false,
                    host: "api-dev.bimplus.net",
                    protocol: "https://"
                }

var api = new BimWebSdk.Api(apiConfig);

Authorization example - obsolete

Please note that authorization must be done prior to any other api calls ! It's important to set correct access token into api to provide credentials for other calls.

...

Application id is the same for all api servers and it identify your application. 


api.authorize.post('demoEmail@allplan.com','password', 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX').done(function(data,status,xhr) {        
    api.setAccessToken(data.access_token);
}).fail(function(data) {     
    console.error('Login to Bimplus failed');
});

Authorization

Please note, authorization must be done prior to any other api calls! To authorize, the best practise is to use browser UI to OIDC server, using discovery URL. The details about connection (and possible changes in settings) can be manually or automatically retrieved there in JSON format.


To try calls in postman, you can specify authorization to 'OAuth 2.0' and set it up there.

To successfully login you need to have account in Allplan Bimplus and application id assigned to your application.

Please note that dev, stage and prod api servers are using separate accounts so it's not possible to login to prod via dev credentials.

Application id is the same for all api servers and it identify your application.

Set team by name function example

Here is the simple example how to obtain list of teams and set specific team by name into api. Api must be authorized otherwise this code will fail.

 


this.setTeamByName = function(teamName){
    var tn = teamName ?  teamName : this.defaultTeam;
    var deferred = $.Deferred();

    // prior the first execution of this code we need to login and set valid api access token into Bimplus WebSDK api
    return api.teams.get().done(function(data){
        var team = data.find(function(d){
            return d.name === tn;
        });

        api.setTeamSlug(team.slug);
        deferred.resolve(team.slug,team.id);
    }).fail(function(result){
        deferred.reject(result);
    });				

};

...

Example how to get list of all projects. Please note that correct access token must be set in api and we must set also the teamslug via api.setTeamSlug(team.slug) call to specify for which team to obtain list of projects 


api.projects.get().done(function(data){    
    deferred.resolve(data);
});