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 added an Rest Server module to the drupal back-end so I can do http requests for retreiving the articles. Now retreiving the articles from the drupal back-end works (see code below). Restdrupal is the name of my site and restendpoint is the name of the Rest server's endpoint (Captian Obvious)
$.ajax({
url : "http://127.0.0.1/restdrupal/restendpoint/node.json",
dataType : 'json',
success : function(data) {
//further code
}
});
Now I want my customer to be able to add some articles, so I need to login first. I've been searching the internet for days now and tried a million things but nothing worked for me. The latest thing i've tried (with jQuery) was this :
$.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
}
});
I've also changed the PUT into POST...
The response i'm getting is (no mather what I do) the same :
406 Not Acceptable: Unsupported request content type application/x-www-form-urlencoded
Could please somebody help me? Kind regards, Ceetn
Found the solution myself. For those who are interested :
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
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