I'm trying to create a user via the REST API. I was able to do it successfully using the REST Client Firefox plugin, but when I actually try to call the URL via code, I get no response. No errors, just nothing. I'm trying to debug the PHP (I am a PHP developer), but cannot for the life of me find the point where the code starts.

I'm doing something like this:

$('#download_trial').click(function() {
            // also need to create email; can we call rest/user/register from here?
            var name = $('#mail').val();
            var data = {
                                "mail":name,
                                "account":{
                                   "name":name,
                                   "pass":generatePassword(),
                                   "mail":name
                                }
                             };
            console.log("data");
            console.log(data);
            $.ajax({
                url:'rest/user/create.json',
                type:"POST",
                data:data,
                contentType:"application/json; charset=utf-8",
                dataType:"json",
                success: function(data){
                    console.log("created user");
                    console.log(data);
                }
              });

I've tried adding a watchdog statement to the _user_resource_create function in user_resource.inc, but it never seems to be getting there. What is the initial entry point for the PHP when rest/user/create.json is called, so that I can try debugging it via my IDE debugger?

Comments

marcingy’s picture

Priority: Major » Normal
kylebrowning’s picture

You can enable debug mode and watchdog will be logging for some services calls.

Chances are you are not getting to the user resource because something else is going wrong along the way.

rasikap’s picture

You can try replacing the url as this, url:'/rest/user/create.json' - / before the url. Also to debug if the url is hit properly, or are there any other errors, you can install firebug, a firefox plugin, using which you can check for errors and debug your problem in the console by inspecting the element.

kylebrowning’s picture

Status: Active » Closed (fixed)