Hey guys,
I can't seem to get off the ground with D7 & Services 3.
I've gone through the documentation, handbook, groups, & google but I just can't figure this out.
I enabled services & rest server, created an end-point "api" with no authentication, enabled all resources and saved.
But I can't get a single services URL to work in curl/firefox poster/chrome/etc. Neither Get/Post. Everything I've tried brings me to Drupal's 404 page.
I have all relevant permissions enabled, clean URLs is on, I have CTools and InputStream installed...
I also have a few nodes and a few users in drupal, so there's even content to be shown.
Nothing.
The bottom of http://drupal.org/node/783722 says:
If you visit this URL in your browser, you should receive a white screen instead of a Page Not Found error. If you get a Page Not Found error, you definitely have something wrong.
Well, I definitely have something wrong :)
Help would be appreciated, I'm feeling pretty stuck.
KJ
Comments
I feel your pain. It took me
I feel your pain. It took me a while (many many weeks) to get my Services stuff off the ground as well. When I get further along in the project I am working on now I plan on writing a long and detailed example to help out any newcomers.
Without knowing your system I would guess that the 404 means that the address you have typed into address bar (or by using GET/POST from some tool) is wrong. This might sound like a 'duh' answer but I got hung up on this very thing myself. If you have the endpoint called 'api' as you say and have the resources completely enabled, then by using poster you should try to login using this info ... http://myIPAddress/myDrupalRootName/api/user/login. I entered in these parameters in the body and then used 'body from parameters': username->admin and password->myAdminsPassword. It should be fairly obvious that you will have to enter in the values for myIPAddress, myDrupalRootName(if you need this, like having a virtual host in apache), and myAdminsPassword. Where I got hung up was using the 'api' endpoint and then calling the 'user'/'login' resource.
Then use a POST and execute the statement. You should see it connect and login. I am not sure if Poster saves the session data so you might not be able to execute another command after this.
Good Luck
Still no go
Hey, thanks for your reply.
Sadly, I got 404s there too.
In my particular case, I don't have any myDrupalRootName as drupal is running at webroot, so I'm using: http://localhost/api/user/login.
Though, with authentication turned off I don't actually need to login, correct? I should be able to GET & POST nodes, users, etc. right away, yes? (for testing)
Also, where do I set access control & permissions for which node types are available to services? I haven't been able to find it, which leads me to think that something is not set up properly. I should be able to specify which node types are available to each endpoint, yes?
Thanks again,
KJ
I am not sure about the
I am not sure about the authentication issue but I believe that even if the authentication is turned off the REST server should still respond to login query.
To access the service controls go into Structure->Services and click on Edit Resources for the 'api'. In there make sure that the 'user' resource has a check box next to it. Then, click the triangle icon next to user. That should show all the resources for 'user'. In there make sure that 'login' is selected. While you are in there just go ahead and make sure the retrieve is enabled as well. Retrieve should get us the info for the admin user with your authentication turned off.
In Poster do a GET with the address http://localhost/api/user/1
That should return you the admin info if authentication is really off or at least tell you that you cannot get that information if the authentication is not completely disabled. That link should also work in your browser as well.
seems to...... work?
A quick update for anyone following:
So I gave up, stuck the project on the backburner for a few days, came back, and now it works.
In the course of my debugging, I disabled all other contrib modules: nothing.
I disabled all services modules & dependancies then re-enabled them all: nothing.
Left it all alone for a few days: now it works.
I'm happy, but puzzled. The only difference between now and then is that cron has run, but that doesn't make sense.
When I first installed services, I hadn't installed inputStream module first, maybe doing things in the wrong order broke it for me?
Anyway, something seems to have done the trick. I'm a little worried about stability in my setup, I don't quite trust that everything is working yet.
But things seem to be (finally) working...
KJ
404 page not found
I've been going around in circles for hours now, trying to get Drupal 7.x & Services 3.x working.
I have followed all the documentation and read everything I can to solve this problem and then I can across this post... guess I'll uninstall it all and try again then...
Update: I've uninstalled and reinstalled everything and still it doesn't work, but, the interesting thing is this... I installed the site locally and installed services and it works. I then went to another Drupal site I have on the same domain and installed Services and it also worked. It just won't work on the site I want it to, almost like the first install corrupted something and now all other attempts are unsuccessfull.
I'm going to backup my site and reinstall the whole site and then add services before putting the data back in to see if this works...
http://www.crayongroup.com/hudson
Managed to resolve this issue
As I didn't want my live site down while I was trying to sort this out, I duplicated it locally.
Once I had an exact copy locally I tested it to see if the issue was still there, it was.
So, I disabled all modules that where not apart of the core. I then enabled Services before any other module.
Once all the modules where re-enabled it all worked as it should. I then put the live site into Maintenance mode and repeated these steps and BAM! it works...
I hate chasing this sort of stuff, it's such a waste of time... I hope this helps the next person to come across this problem, sooner.
http://www.crayongroup.com/hudson
interesting!
I'm with you on this being an annoying problem to have chased down, and I'm glad that you did. It reminds me of another scenario I had once where environments were somewhat out of sync and difficult to troubleshoot. In those cases, there was a module in the
systemtable with the wrong weight. Services.install doesn't specify a weight for itself, so it should be set to '0' by default. However, some other module on which it depended may have had a higher weight, invoking it after services, even in a bootstrap, where module_list http://api.drupal.org/api/drupal/includes--module.inc/function/module_list calls system_list http://api.drupal.org/api/drupal/includes--module.inc/function/system_li... which orders by weight. I've also seen cases where a module or two was installed in the wrong directory on the first go, which can also mess with the system_list call when it comes down to it.(In my case it was an access control / perms issue.)
Anyway, if you have a copy of that old offending db around and can
select name, filename, weight from system order by name, weight;, that might point out the actual culprit, or that some modules were registered as having lived in the wrong place once (which can lead to two battlingsystementries!).Ditto... Same issue
I've also got the same issue here... So annoying!
Tried Hudson Graham's suggestion and that did not work, even when I only installed Chaos Tools and Services only.
Maybe try also uninstalling
Maybe try also uninstalling all the modules to clear the DB then re-activate them all with CTools first then Services...
Let us know how you go.
http://www.crayongroup.com/hudson
Fixed now
Followed through the recommendation and it all works now! Thanks for your help.
404 Not found: Couldn't find controller using POST and REST
Hello everyone,
I have almost tried all the mentioned tips.. My custom service resources are still not working right. They return wrong results on GET and PUT.. while they return 404 using POST.
There must be something wrong with services module. Looks like it doesn't map resources to the menu system right!
Any ideas?
Admin contrib module
In my case I think it is Admin contrib module.
Edit: Oops, reenabling Admin and the Service REST protocol is still available in /api. Maybe something to do with the menu rebuild on step 2.
Solution found!
I found that we can reproduce this issue when the DocumentRoot in Apache is set to /var/www/ and your site is located under /var/www/somesite/ and you set your end point path as "rest".
With above mentioned settings, when you open up a browser which points to http://site/somesite/rest/node, you shall get a 404 error
Then take a look at the apache log, you will find that the server is actually trying to access http://site/index.php instead of http://site/somesite/index.php
To fix the issue.
Change your DocumentRoot to be the same as the root folder of your Drupal site.
Additional information
I was having 404 issues, as reported by so many here. I tried all of the steps mentioned. Also what yuchuan1 had suggested. (was actually one of the first things I had tried).
How I solved my problem:
It turns out that I didn't have .htaccess override turned on in my apache config. This made the provided .htaccess config not provide anything. This meant that "clean urls" wasn't enabled in drupal.
If you look through this stack overflow you will see that they are reaching the service via get parameters "q=" sorts of syntax.
http://stackoverflow.com/questions/20532019/drupal-services-endpoint-ret...
Using something like this I was able to verify that my service was indeed working, but my routing was messed up. I got .htaccess override enabled, restarted apache, and things started working fine!
I suspect the same for yuchuan1, that they would perhaps need to make some custom changes to the .htaccess to point to the sub-directory.
Something else to check
I had the same problem, in my case it turns out I needed create a resource for each operation crud and index. Without them all, I got a 404 controller not found.