RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.4k stars 10.51k forks source link

rooms.createDiscussion API returns invalid HTML response #14458

Closed SibeeshVenu closed 5 years ago

SibeeshVenu commented 5 years ago

Description:

I am trying to create a room from my Angular application using HttpClient by following this post but I am always getting an error as below.

ERROR Error: Uncaught (in promise): HttpErrorResponse: {"headers":{"normalizedNames":{},"lazyUpdate":null},"status":200,"statusText":"OK","url":"myurl/rocketchat/api/v1/rooms.createDiscussion","ok":false,"name":"HttpErrorResponse","message":"Http failure during parsing for myrul/rocketchat/api/v1/rooms.createDiscussion","error":{"error":{},"text":"

I am able to use the login API, and I am getting a correct response.

Steps to reproduce:

  1. Follow this post
  2. I have also tried using the curl as mentioned in the examples

curl -H "X-Auth-Token: token" -H "X-User-Id: userid" -H "Content-Type: application/json" myurl/rocketchat/api/v1/rooms.createDiscussion -d '{ "prid": "GENERAL", "t_name": "Discussion Name"}'

But getting an HTML response instead of an actual JSON response.

<!DOCTYPE html>
<html>
<head>
<meta name="referrer" content="origin-when-crossorigin">
<script>/* eslint-disable */

'use strict';
(function() {
        var debounce = function debounce(func, wait, immediate) {

Expected behavior:

Should return a response as below.

{
    "discussion": {
        "rid": "cgk88DHLHexwMaFWh",
        "name": "WJNEAM7W45wRYitHo",
        "fname": "Discussion Name",
        "t": "p",
        "msgs": 0,
        "usersCount": 0,
        "u": {
            "_id": "rocketchat.internal.admin.test",
            "username": "rocketchat.internal.admin.test"
        },
        "topic": "general",
        "prid": "GENERAL",
        "ts": "2019-04-03T01:35:32.271Z",
        "ro": false,
        "sysMes": true,
        "default": false,
        "_updatedAt": "2019-04-03T01:35:32.280Z",
        "_id": "cgk88DHLHexwMaFWh"
    },
    "success": true
}

Actual behavior:

The API returns an Invalid HTML response.

Server Setup Information:

Please let me know how can I fix this. Thanks in advance.

MarcosSpessatto commented 5 years ago

@SibeeshVenu as you can see in the changelog, this endpoint has been added only in 1.0.0. Your server version is 0.74.2, you are getting this error because this endpoint does not exist in your server.

SibeeshVenu commented 5 years ago

@MarcosSpessatto Thanks a lot for the response. Updating to the newest version fixed my issue.

smcardle commented 5 years ago

I would like this issue re-opened as I am having the exact same issue.

My RocketChat server version is 1.1.0

After a successful login with a user that has start-discussion permissions and then calling POST on /api/v1/rooms.createDiscussion with the correct X-Auth-Token and X-User-Id as returned from the login, the response returns a HUGE amount of HTML code and NOT a discussion object as defined above in SibeeshVenu post or on the Rocket.Chat REST page https://rocket.chat/docs/developer-guides/rest-api/rooms/creatediscussion/

Regards

Steve