gpt4 book ai didi

jquery - 通过Rest服务器登录Drupal

转载 作者:行者123 更新时间:2023-12-03 22:43:03 26 4
gpt4 key购买 nike

我正在开发一个网站,该网站使用外部 Drupal 来显示文章和页面。目的是仅使用 html/css/js 显示网站中的文章。

我在 drupal 后端添加了一个 Rest Server 模块,这样我就可以执行 http 请求来检索文章。现在从 drupal 后端工程中检索文章(参见下面的代码)。 Restdrupal 是我的站点的名称,restendpoint 是 Rest 服务器端点的名称 (Captian Obvious)

$.ajax({
url : "http://127.0.0.1/restdrupal/restendpoint/node.json",
dataType : 'json',
success : function(data) {
//further code
}
});

现在我希望我的客户能够添加一些文章,所以我需要先登录。我已经在互联网上搜索了好几天,尝试了一百万种方法,但没有任何对我有用。我最近尝试过的事情(使用 jQuery)是这样的:

$.ajax({
url : "http://127.0.0.1/restdrupal/restendpoint/user/login",
dataType:'application/json',
type : 'PUT',
data : 'Name=myusername&Pass=mypassword',
success : function(data) {
//further code
},
error:function(data){
//Error handling
}
});

我还将 PUT 更改为 POST...

我得到的回应(无论我做什么)都是一样的:

406 Not Acceptable: Unsupported request content type application/x-www-form-urlencoded

请问有人可以帮助我吗?亲切的问候,塞特恩

最佳答案

您必须启用服务端点的 application/x-www-form-urlencoded 内容类型。

按如下操作:服务 -> 编辑资源 -> 选择选项卡“服务器” -> 启用“application/x-www-form-urlencoded”,就这样

关于jquery - 通过Rest服务器登录Drupal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8535820/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com