{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/2078","repository_url":"https://api.github.com/repos/Microsoft/BotBuilder","labels_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/2078/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/2078/comments","events_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/2078/events","html_url":"https://github.com/Microsoft/BotBuilder/issues/2078","id":202181252,"number":2078,"title":"DIRECT LINE API Return 500 internal server error when calling with Jquery Ajax","user":{"login":"sayyednazeer","id":10753866,"avatar_url":"https://avatars.githubusercontent.com/u/10753866?v=3","gravatar_id":"","url":"https://api.github.com/users/sayyednazeer","html_url":"https://github.com/sayyednazeer","followers_url":"https://api.github.com/users/sayyednazeer/followers","following_url":"https://api.github.com/users/sayyednazeer/following{/other_user}","gists_url":"https://api.github.com/users/sayyednazeer/gists{/gist_id}","starred_url":"https://api.github.com/users/sayyednazeer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sayyednazeer/subscriptions","organizations_url":"https://api.github.com/users/sayyednazeer/orgs","repos_url":"https://api.github.com/users/sayyednazeer/repos","events_url":"https://api.github.com/users/sayyednazeer/events{/privacy}","received_events_url":"https://api.github.com/users/sayyednazeer/received_events","type":"User","site_admin":false},"labels":[{"id":516903567,"url":"https://api.github.com/repos/Microsoft/BotBuilder/labels/directline","name":"directline","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":{"login":"dandriscoll","id":5069805,"avatar_url":"https://avatars.githubusercontent.com/u/5069805?v=3","gravatar_id":"","url":"https://api.github.com/users/dandriscoll","html_url":"https://github.com/dandriscoll","followers_url":"https://api.github.com/users/dandriscoll/followers","following_url":"https://api.github.com/users/dandriscoll/following{/other_user}","gists_url":"https://api.github.com/users/dandriscoll/gists{/gist_id}","starred_url":"https://api.github.com/users/dandriscoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dandriscoll/subscriptions","organizations_url":"https://api.github.com/users/dandriscoll/orgs","repos_url":"https://api.github.com/users/dandriscoll/repos","events_url":"https://api.github.com/users/dandriscoll/events{/privacy}","received_events_url":"https://api.github.com/users/dandriscoll/received_events","type":"User","site_admin":false},"assignees":[{"login":"dandriscoll","id":5069805,"avatar_url":"https://avatars.githubusercontent.com/u/5069805?v=3","gravatar_id":"","url":"https://api.github.com/users/dandriscoll","html_url":"https://github.com/dandriscoll","followers_url":"https://api.github.com/users/dandriscoll/followers","following_url":"https://api.github.com/users/dandriscoll/following{/other_user}","gists_url":"https://api.github.com/users/dandriscoll/gists{/gist_id}","starred_url":"https://api.github.com/users/dandriscoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dandriscoll/subscriptions","organizations_url":"https://api.github.com/users/dandriscoll/orgs","repos_url":"https://api.github.com/users/dandriscoll/repos","events_url":"https://api.github.com/users/dandriscoll/events{/privacy}","received_events_url":"https://api.github.com/users/dandriscoll/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2017-01-20T16:20:58Z","updated_at":"2017-01-20T18:12:49Z","closed_at":null,"body":"My bot works fine on emulator and webchat channel. But with direct line api  it returns  500 internal server error messages.\r\n\r\n **POST https://directline.botframework.com/api/conversations/BQf8iT1aU3ULgU4VRN2TSF/messages 500 (Internal Server Error)**\r\n\r\ni am calling it using jquery ajax, below is my code how i make a call\r\n\r\n----// calling this on document.ready method and Gettting conversation id in a variable\r\n\r\n function GetId() {\r\n            var directLineSecret = '<%=ConfigurationManager.AppSettings[\"SECRET\"].ToString() %>';\r\n            $.ajax({\r\n                method: \"POST\",\r\n                crossDomain: true,\r\n                contentType: \"application/json\",\r\n                headers: {\r\n                    Authorization: \"Botconnector \" + directLineSecret\r\n                },\r\n                url: \"https://directline.botframework.com/api/conversations\",\r\n                success: function (data) {\r\n\r\n                    console.log(data);\r\n                    convId = data.conversationId;\r\n                },\r\n                error: function (XMLHttpRequest, textStatus, errorThrown) {\r\n                    console.log(XMLHttpRequest);\r\n                    console.log(textStatus);\r\n                    console.log(errorThrown);\r\n                  \r\n                }\r\n            });\r\n        };\r\n\r\n----/// calling this method on html button click -->>> this method return internal error 500\r\n\r\nfunction sendMessage(convId, msg) {\r\n            debugger;\r\n            var directLineSecret = '<%=ConfigurationManager.AppSettings[\"SECRET\"].ToString() %>';\r\n\r\n\r\n            var user = \"user_\" + convId; // \r\n                        \r\n            \r\n\r\n            $.ajax({\r\n                method: \"POST\",\r\n                contentType: \"application/json\",\r\n                headers: {\r\n                    'Content-Type': 'application/json; charset=utf-8',\r\n                    Authorization: \"Botconnector \" + directLineSecret\r\n                },\r\n                url: 'https://directline.botframework.com/api/conversations/' + convId + '/messages',\r\n                data: JSON.stringify({\r\n                    conversationId: convId,\r\n                    \"text\": msg, //\r\n                    \"from\": user //\r\n                }),\r\n                success: function (obj) {\r\n                    debugger;\r\n                    console.log(\"Message Sent!\");\r\n                    getMessage(convId);\r\n                },\r\n                error: function (err) {\r\n                   \r\n                   alert(err);\r\n                   \r\n                }\r\n            });\r\n\r\n        }\r\n\r\n---/////   if send success get message\r\n\r\nfunction getMessage(convId, watermark) {\r\n            debugger;\r\n            var url;\r\n\r\n            if (watermark) {\r\n                url = \"https://directline.botframework.com/api/conversations/\" + convId + \"/messages?watermark=\" + watermark;\r\n            } else {\r\n                //url = \"https://directline.botframework.com/api/conversations/\" + convId + \"/messages?watermark=\" + watermark;\r\n                url = \"https://directline.botframework.com/api/conversations/\" + convId + \"/messages\";\r\n            }\r\n\r\n            return $.ajax({\r\n                method: \"GET\",\r\n                contentType: \"application/json\",\r\n                headers: {\r\n                    Authorization: \"Botconnector \" + directLineSecret\r\n                },\r\n                url: url,\r\n                success: function (data) {\r\n                    debugger;\r\n                    console.log('get message success')\r\n                    console.log(JSON.stringify(data));\r\n\r\n\r\n                    });\r\n\r\n                    watermark = data.watermark;\r\n                    //\r\n                    var date = new Date();\r\n                    date.setTime(date.getTime() + (30 * 60 * 1000));\r\n                    $.cookie(\"watermark\", data.watermark, {\r\n                        expires: date\r\n                    });\r\n\r\n\r\n                },\r\n                error: function (err) {\r\n\r\n                    alert(err);\r\n\r\n                }\r\n            });\r\n        }\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/comments/274140234","html_url":"https://github.com/Microsoft/BotBuilder/issues/2078#issuecomment-274140234","issue_url":"https://api.github.com/repos/Microsoft/BotBuilder/issues/2078","id":274140234,"user":{"login":"dandriscoll","id":5069805,"avatar_url":"https://avatars.githubusercontent.com/u/5069805?v=3","gravatar_id":"","url":"https://api.github.com/users/dandriscoll","html_url":"https://github.com/dandriscoll","followers_url":"https://api.github.com/users/dandriscoll/followers","following_url":"https://api.github.com/users/dandriscoll/following{/other_user}","gists_url":"https://api.github.com/users/dandriscoll/gists{/gist_id}","starred_url":"https://api.github.com/users/dandriscoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dandriscoll/subscriptions","organizations_url":"https://api.github.com/users/dandriscoll/orgs","repos_url":"https://api.github.com/users/dandriscoll/repos","events_url":"https://api.github.com/users/dandriscoll/events{/privacy}","received_events_url":"https://api.github.com/users/dandriscoll/received_events","type":"User","site_admin":false},"created_at":"2017-01-20T18:12:49Z","updated_at":"2017-01-20T18:12:49Z","body":"Hi @sayyednazeer, in Direct Line 1.1, we will return HTTP 500 when your bot generates an error. In this case, your bot's endpoint is returning an HTTP 500 to us, so we return it to your client.\r\n\r\n(In Direct Line 3.0, we return a different error code so you can tell the difference between your bot's errors and our internal service errors.)"}}
{"actor":{"display_login":"dandriscoll"}}