Delete User Session

Purpose 

To delete a user session of a particular document in Zoho Writer.

HTTP Request URL

https://{api.office-integrator_domain}/writer/officeapi/v1/sessions/<session_id>?apikey=<apikey>

Request Parameters

ParameterData TypeDescription
Mandatory Parameters
apikeyStringUniquely identifies the web application in which the Writer editor is integrated.
session_idStringUnique user session id of the document.

Note:

Users can find the 'session_id' in all Zoho Writer API responses. For example, the "session_id" is captured as part of the response and can be seen in Preview, Edit and Comparison APIs.

Sample Request

Copiedhttps://api.office-integrator.com/writer/officeapi/v1/sessions/d26aa7b8029bf4f8d34c7dd00139392357d12ffcb21c1?apikey=423s*****
Copiedconst Levels = require("zoi-nodejs-sdk/routes/logger/logger").Levels;
const Constants = require("zoi-nodejs-sdk/utils/util/constants").Constants;
const APIKey = require("zoi-nodejs-sdk/models/authenticator/apikey").APIKey;
const Environment = require("zoi-nodejs-sdk/routes/dc/environment").Environment;
const LogBuilder = require("zoi-nodejs-sdk/routes/logger/log_builder").LogBuilder;
const UserSignature = require("zoi-nodejs-sdk/routes/user_signature").UserSignature;
const InitializeBuilder = require("zoi-nodejs-sdk/routes/initialize_builder").InitializeBuilder;

const CreateDocumentParameters = require("zoi-nodejs-sdk/core/com/zoho//officeintegrator/office_integrator_sdk/create_document_parameters").CreateDocumentParameters;
const SessionDeleteSuccessResponse = require("zoi-nodejs-sdk/core/com/zoho//officeintegrator/office_integrator_sdk/session_delete_success_response").SessionDeleteSuccessResponse;
const InvaildConfigurationException = require("zoi-nodejs-sdk/core/com/zoho//officeintegrator/office_integrator_sdk/invaild_configuration_exception").InvaildConfigurationException;
const OfficeIntegratorSDKOperations = require("zoi-nodejs-sdk/core/com/zoho//officeintegrator/office_integrator_sdk/office_integrator_sdk_operations").OfficeIntegratorSDKOperations;

class DeleteDocumentSession {

    //Include zoi-nodejs-sdk package in your package json and the execute this code.

    static async initializeSdk() {
        let user = new UserSignature("john@zylker.com");
        let environment = new Environment("https://api.office-integrator.com", null, null);
        let apikey = new APIKey("2ae438cf864488657cc9754a27daa480", Constants.PARAMS);
        let logger = new LogBuilder()
            .level(Levels.INFO)
            .filePath("./app.log")
            .build();
        let initialize = await new InitializeBuilder();

        await initialize.user(user).environment(environment).token(apikey).logger(logger).initialize();

        console.log("\nSDK initialized successfully.");
    }

    static async execute() {
        
        //Initializing SDK once is enough. Calling here since code sample will be tested standalone. 
        //You can place SDK initializer code in your application and call once while your application start-up. 
        await this.initializeSdk();

        try {
            var createDocumentParameters = new CreateDocumentParameters();
            var sdkOperations = new OfficeIntegratorSDKOperations();

            var createResponse = await sdkOperations.createDocument(createDocumentParameters);

            var sessionId = createResponse.object.getSessionId();

            console.log("\nCreated a session to demonstrate the session delete api. Created document session ID - " + sessionId);

            var responseObject = await sdkOperations.deleteSession(sessionId);

            if(responseObject != null) {
                //Get the status code from response
                console.log("\nStatus Code: " + responseObject.statusCode);
    
                //Get the api response object from responseObject
                let writerResponseObject = responseObject.object;
    
                if(writerResponseObject != null){
                    if(writerResponseObject instanceof SessionDeleteSuccessResponse){
                        console.log("\nSession delete status - " + writerResponseObject.getSessionDelete());
                    } else if (writerResponseObject instanceof InvaildConfigurationException) {
                        console.log("\nInvalid configuration exception. Exception json - ", writerResponseObject);
                    } else {
                        console.log("\nRequest not completed successfullly");
                    }
                }
            }
        } catch (error) {
            console.log("\nException while running sample code", error);
        }
    }
}

DeleteDocumentSession.execute();

Sample Response

Copied{
    "session_delete": true
}