# Configuration for Recording in Rest API

**URL:** <https://openvidu.discourse.group/t/configuration-for-recording-in-rest-api/2084>\
**Category:** Issues developing apps\
**Tags:** v2\
**Created:** [September 29, 2020, 7:00pm UTC](https://openvidu.discourse.group/t/configuration-for-recording-in-rest-api/2084 "2020-09-29T19:00:27Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![hemalatha](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@hemalatha](https://openvidu.discourse.group/u/hemalatha)\
**Post date:** [September 29, 2020, 7:00pm UTC](https://openvidu.discourse.group/t/configuration-for-recording-in-rest-api/2084/1 "2020-09-29T19:00:27Z")

</div>

\*\*Where should i set true to recording property . I created session api as like below. but recording value will always returning false.  
Dont know where to configure for enabling recording as true in REST API.

Kindly help to resolve this issue.\*\*

```auto
    createSession(sessionId) {
        return new Promise((resolve, reject) => {
            var data = JSON.stringify({ customSessionId: sessionId,
                "recording": true,
                "mediaMode": "ROUTED",
                "recordingMode": "ALWAYS",
                "defaultOutputMode": "COMPOSED",
                "defaultRecordingLayout": "BEST_FIT"});
            axios
                .post(OPENVIDU_SERVER_URL + '/api/sessions', data, {
                    headers: {
                        Authorization: 'Basic ' + btoa('OPENVIDUAPP:' + OPENVIDU_SERVER_SECRET),
                        'Content-Type': 'application/json',
                    },
                })
                .then((response) => {
                    console.log('CREATE SESION', response);
                    //alert(response.OPENVIDU_STREAMS_VIDEO_MAX_RECV_BANDWIDTH);
                    fetch(OPENVIDU_SERVER_URL + '/api/sessions/'+sessionId , {
                        method: 'GET',
                        headers: {
                            Authorization: 'Basic ' + btoa('OPENVIDUAPP:' + OPENVIDU_SERVER_SECRET),
                            'Content-Type': 'application/json',
                        }
                    })
                        .then(res => res.json())
                        .then(
                            (result) => {
                                console.log("GETSESS"+result.recording);//Always returning false
    
                            },
                            (error) => {
                                alert(error);
                                console.log(error);
                            }
                        );
                    resolve(response.data.id);
                })
                .catch((response) => {
                    var error = Object.assign({}, response);
                    if (error.response.status === 409) {
                        resolve(sessionId);
                    } else {
                        console.log(error);
                        console.warn(
                            'No connection to OpenVidu Server. This may be a certificate error at ' +
                            OPENVIDU_SERVER_URL,
                        );
                        if (
                            window.confirm(
                                'No connection to OpenVidu Server. This may be a certificate error at "' +
                                OPENVIDU_SERVER_URL +
                                '"\n\nClick OK to navigate and accept it. ' +
                                'If no certificate warning is shown, then check that your OpenVidu Server is up and running at "' +
                                OPENVIDU_SERVER_URL +
                                '"',
                            )
                        ) {
                            window.location.assign(OPENVIDU_SERVER_URL + '/accept-certificate');
                        }
                    }
                });
        });
    }

```

---

<div class="post-metadata">

**Author:** ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)\
**Post date:** [September 30, 2020, 4:18am UTC](https://openvidu.discourse.group/t/configuration-for-recording-in-rest-api/2084/2 "2020-09-30T04:18:01Z")

</div>

@hemalatha, no need to pass **“recording”:true** while creating Session. You need to enable the Recording from the config file.

- Go to openVidu installation folder, in most cases it would be “ **/opt/openvidu** ”.
- Edit the " **.env"** file e.g **sudo nano .env**
- Search for the “ **OPENVIDU\_RECORDING** ” and change the value from false to true.  
OPENVIDU\_RECORDING=true
- Restart the openvidu services  
and then try the Rest API to check the same.

---

<div class="post-metadata">

**Author:** ![hemalatha](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@hemalatha](https://openvidu.discourse.group/u/hemalatha)\
**Post date:** [September 30, 2020, 4:38am UTC](https://openvidu.discourse.group/t/configuration-for-recording-in-rest-api/2084/3 "2020-09-30T04:38:28Z")

</div>

@rohit.roy… Thanks for reply but I am usin Reacjjs, in node\_modules there is no .env file. i checked and i didnt find **/opt/openvidu**

---

<div class="post-metadata">

**Author:** ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)\
**Post date:** [September 30, 2020, 4:43am UTC](https://openvidu.discourse.group/t/configuration-for-recording-in-rest-api/2084/4 "2020-09-30T04:43:45Z")

</div>

@hemalatha, .env file is the part of Openvidu installation. Where have you installed Openvidu and how you start the Openvidu services.

---

<div class="post-metadata">

**Author:** ![hemalatha](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@hemalatha](https://openvidu.discourse.group/u/hemalatha)\
**Post date:** [September 30, 2020, 4:50am UTC](https://openvidu.discourse.group/t/configuration-for-recording-in-rest-api/2084/5 "2020-09-30T04:50:26Z")

</div>

@rohit.roy… deployed openvidu in aws by using cloud formation as like in aws deployment in docs of openvidu website. and in reactjs components, openvidu-browser installed by command : npm install openvidu-browser…attached image for reference

 ![ov](https://global.discourse-cdn.com/free1/uploads/openvidu/original/2X/7/7dff8db0b698f42b0e5f47e30d5b0d27a731c051.jpeg)

---

<div class="post-metadata">

**Author:** ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)\
**Post date:** [September 30, 2020, 4:54am UTC](https://openvidu.discourse.group/t/configuration-for-recording-in-rest-api/2084/6 "2020-09-30T04:54:00Z")

</div>

You need to enable recording on openvidu server. Login to your EC2 instance and change in .env file over there.

---

<div class="post-metadata">

**Author:** ![hemalatha](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@hemalatha](https://openvidu.discourse.group/u/hemalatha)\
**Post date:** [September 30, 2020, 4:54am UTC](https://openvidu.discourse.group/t/configuration-for-recording-in-rest-api/2084/7 "2020-09-30T04:54:55Z")

</div>

@rohit.roy… Thank u … i do and let u know

---

<div class="post-metadata">

**Author:** ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)\
**Post date:** [September 30, 2020, 5:23am UTC](https://openvidu.discourse.group/t/configuration-for-recording-in-rest-api/2084/8 "2020-09-30T05:23:06Z")

</div>

okay, also i see the create token, session connect and Publish session is missing in your code. To record the session properly, stream should be published. So the sequence should be like this to record the session properly.

- Initialise session object (using method initSession())
- Create session
- Create token with PUBLISHER role
- Connect session with the token received (using method session.connect() )
- Initiate Publisher ( using method initPublihser() )
- Publish session ( using session.publish() )

---

<div class="post-metadata">

**Author:** ![hemalatha](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@hemalatha](https://openvidu.discourse.group/u/hemalatha)\
**Post date:** [October 5, 2020, 8:24am UTC](https://openvidu.discourse.group/t/configuration-for-recording-in-rest-api/2084/9 "2020-10-05T08:24:43Z")

</div>

@rohit.roy. i used these points in joinsession function. In AWS, in EC2 , i just mapped created ip in ec2 to site like [https://xxxx.co.in](https://xxxx.co.in) with letsEncrypt. can u help to find where .env file located?

---

<div class="post-metadata">

**Author:** ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)\
**Post date:** [October 5, 2020, 10:47am UTC](https://openvidu.discourse.group/t/configuration-for-recording-in-rest-api/2084/10 "2020-10-05T10:47:59Z")

</div>

Default installation path **`/opt/openvidu`** as `root` user ( `$ sudo su` ).  
SSH the AWS server and go to this directory to edit the .env file.

Or you can try searching it from Console like this  
**locate .env**

---

<div class="post-metadata">

**Author:** ![hemalatha](https://avatars.discourse-cdn.com/v4/letter/h/dfb087/32.png) [@hemalatha](https://openvidu.discourse.group/u/hemalatha)\
**Post date:** [October 7, 2020, 11:48am UTC](https://openvidu.discourse.group/t/configuration-for-recording-in-rest-api/2084/11 "2020-10-07T11:48:29Z")

</div>

@rohit.roy … Thank u… Successfully configured.
