# Issue with openvidu REST API (Create a new Connection in the Session)

**URL:** <https://openvidu.discourse.group/t/issue-with-openvidu-rest-api-create-a-new-connection-in-the-session/3467>\
**Category:** Issues developing apps\
**Tags:** v2\
**Created:** [October 7, 2021, 6:45pm UTC](https://openvidu.discourse.group/t/issue-with-openvidu-rest-api-create-a-new-connection-in-the-session/3467 "2021-10-07T18:45:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_Taylor](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/sean_taylor/32/1314_2.png) [@Sean\_Taylor](https://openvidu.discourse.group/u/Sean_Taylor)\
**Post date:** [October 7, 2021, 6:45pm UTC](https://openvidu.discourse.group/t/issue-with-openvidu-rest-api-create-a-new-connection-in-the-session/3467/1 "2021-10-07T18:45:46Z")

</div>

Hi Team  
I am using [openvidu-angular](https://docs.openvidu.io/en/2.20.0/tutorials/openvidu-library-angular/) (2.20.0)  
I am facing issues while creating a new connection in the Session using REST API.  
I followed the syntax from [https://docs.openvidu.io/en/stable/reference-docs/REST-API/#post-connection](https://docs.openvidu.io/en/stable/reference-docs/REST-API/#post-connection)

```auto
createToken(sessionId): Promise<string> {
    return new Promise((resolve, reject) => {
      const body = JSON.stringify({type:"WEBRTC",data:"100021",role:"PUBLISHER"});
      const options = {
        headers: new HttpHeaders({
          Authorization: 'Basic ' + btoa('OPENVIDUAPP:' + this.OPENVIDU_SERVER_SECRET),
          'Content-Type': 'application/json',
        }),
      };
      return this.httpClient
        .post(this.OPENVIDU_SERVER_URL + '/openvidu/api/sessions/' + sessionId + '/connection', body, options)
        .pipe(
          catchError((error) => {
            reject(error);
            return observableThrowError(error);
          }),
        )
        .subscribe((response) => {
          resolve(response['token']);
        });
    });
}

```

I want to send “custom user id” information to openvidu media server for all users joining session. so I tried to add “My Server Data” in body as shown in the document. But other users are not able to join my session(It shows unknown). Please check the below screenshot.

 ![Virtual-Office-Inter-Office-User-to-User-Webcam](https://global.discourse-cdn.com/free1/uploads/openvidu/original/2X/6/6e97fad8f7db47d29a36a71675ed9ee153be2263.jpeg)

but everything is working fine when removing the “data” field in body.

Can somebody please help me with this issue?  
Thanks for your attention. I’m looking forward to your reply.

---

<div class="post-metadata">

**Author:** ![ilampirai\_nambi](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/ilampirai_nambi/32/1732_2.png) [@ilampirai\_nambi](https://openvidu.discourse.group/u/ilampirai_nambi)\
**Post date:** [November 2, 2021, 4:20pm UTC](https://openvidu.discourse.group/t/issue-with-openvidu-rest-api-create-a-new-connection-in-the-session/3467/2 "2021-11-02T16:20:39Z")

</div>

having the same issue, cant add our custom data in meeting session

---

<div class="post-metadata">

**Author:** ![pabloFuente](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/pablofuente/32/2536_2.png) [@pabloFuente](https://openvidu.discourse.group/u/pabloFuente)\
**Post date:** [November 3, 2021, 9:22am UTC](https://openvidu.discourse.group/t/issue-with-openvidu-rest-api-create-a-new-connection-in-the-session/3467/3 "2021-11-03T09:22:56Z")

</div>

The application is using the client data to set the user name. You can provide user data in two different ways: on the server side when creating the Connection object, using “data” parameter, or in the client side when calling [Session.connect](https://docs.openvidu.io/en/stable/api/openvidu-browser/classes/session.html#connect) (using “metadata” parameter).

Here is the complete information about how you can easily sharing information about users, explaining these two methods:  
[https://docs.openvidu.io/en/stable/cheatsheet/share-data/](https://docs.openvidu.io/en/stable/cheatsheet/share-data/)

openvidu-angular is using the client side data to set the username. You can see the code right here: [openvidu-call/utils.service.ts at master · OpenVidu/openvidu-call · GitHub](https://github.com/OpenVidu/openvidu-call/blob/master/openvidu-call-front/src/app/shared/services/utils/utils.service.ts#L118).

If that JSON.parse fails, then “Unknown” will be used.

---

<div class="post-metadata">

**Author:** ![pabloFuente](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/pablofuente/32/2536_2.png) [@pabloFuente](https://openvidu.discourse.group/u/pabloFuente)\
**Post date:** [November 3, 2021, 9:31am UTC](https://openvidu.discourse.group/t/issue-with-openvidu-rest-api-create-a-new-connection-in-the-session/3467/4 "2021-11-03T09:31:22Z")

</div>

openvidu-angular is using only the client side way, but it needs a JSON object like this for the method `getNicknameFromConnectionData` that I linked above to properly work. Something like this:

```auto
session.connect(token, { clientData: 'USER NAME', avatar: 'AVATAR' });

```

---

<div class="post-metadata">

**Author:** ![Joshua\_Kelvyn](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/joshua_kelvyn/32/1733_2.png) [@Joshua\_Kelvyn](https://openvidu.discourse.group/u/Joshua_Kelvyn)\
**Post date:** [November 11, 2021, 9:52pm UTC](https://openvidu.discourse.group/t/issue-with-openvidu-rest-api-create-a-new-connection-in-the-session/3467/5 "2021-11-11T21:52:50Z")

</div>

I have same issues. It makes me crazy.  
If you have any solution, please share with me.

Thank you.
