为什么我收到错误登录尝试失败请检查用户名和密码

时间:2016-03-10 21:50:20

标签: jquery json sugarcrm

虽然我也传递了正确的用户名和密码,但我收到同样的错误。

 <html>
    <head>
      <meta content="HTML Tidy for Java (vers. 27 Sep 2004), see www.w3.org" name="generator"/>
      <title/>
    </head>
   <body>{"name":"Invalid Login","number":10,"description":"Login attempt failed please check the username and password"}</body>
</html>

我正在提供JSON请求

http://sugarcrmpgsql-shiruslabs.rhcloud.com/service/v4_1/rest.php?rest_data={"user_auth":{"user_name":"admin","password":"admin","version":"1"},"application_name":"SugarCRM REST API","name_value_list":[]}&"input_type"="JSON"&"response_type"="JSON"&"method"="login"

1 个答案:

答案 0 :(得分:0)

请从phpMyAdmin更改用户密码。

        var params = {
            user_auth:{
                user_name: "ENTER USERNAME",
                password: "ENTER PASSWORD",
                encryption: 'PLAIN'
            },
            application: 'RestAPI'
        }
        var json = JSON.stringify(params);

        var loginParam = jQuery.param({
            method : "login",
            input_type : "JSON",
            response_type : "JSON",
            rest_data : json
        });

        $http({
            url: BASE_URL + 'service/v4_1/rest.php',
            method: 'POST',
            dataType: 'JSON',
            data: loginParam,
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded charset=UTF-8'
            },
        }).success(function(response){
            if(response.id)
            {
                console.log("Success");
            }
            else
            {
                alert('Please Enter Correct Username and Password');
            }
        }).error(function(error){
            alert('Please Enter Correct Username and Password');
        });