Drupal login via Rest server

前端 未结 3 1720
盖世英雄少女心
盖世英雄少女心 2021-01-03 01:19

I\'m developing a website who uses an external Drupal for the articles and pages. The purpose is to show the articles in a website using just html/css/js.

I\'ve adde

相关标签:
3条回答
  • 2021-01-03 01:28

    might need to enable that parser type?

    check this link out. maybe it will help you get some ideas https://drupal.stackexchange.com/questions/3207/simple-rest-request-to-create-nodes

    0 讨论(0)
  • 2021-01-03 01:41

    You have to enable application/x-www-form-urlencoded content type of your service endpoint.

    Do as follows: Services -> Edit Resources -> select tab "Server" -> enable "application/x-www-form-urlencoded" and that's it

    0 讨论(0)
  • 2021-01-03 01:48

    Found the solution myself. For those who are interested :

    $.ajax({
        url : "http://127.0.0.1/restdrupal/restpoint/user/login.json",
        type : 'post',
        data : 'username=' + encodeURIComponent(username) + '&password=' + encodeURIComponent(password),
        dataType : 'json',
        error : function(data) {
                //error code
        },
        success : function(data) {
            //success code
        }
    });
    
    0 讨论(0)
提交回复
热议问题