Hi,
I installed the services module (3.0 rc1) and all its requirements on a fresh D7 install. My goal is to expose my customized multi-user blog content as a REST service based on taxonomy categories. I created a REST server service which I can access from a test rest client I've written in Zend Framework. For some reason I always get html as a return, no matter what format I specify. Is there something I'm missing out?
These two code blocks both return the same content
$uri = 'http://local.test/services/rest';
$client = new Zend_Rest_Client($uri);
$result = $client->restGet('node/8.json');
echo $result->getBody();
$uri = 'http://local.test/services/rest';
$client = new Zend_Rest_Client($uri);
$result = $client->restGet('node/8');
echo $result->getBody();
Comments
Comment #1
kylebrowning commentedTry the dev version first and let me know if this is still an issue.
Comment #2
edmeister commentedHi Kyle,
The dev version gives an error when loading the resources tab for a new service.
Warning: Parameter 1 to services_edit_form_endpoint_resources() expected to be a reference, value given in drupal_retrieve_form() (line 771 of [PATH]/drupal/includes/form.inc).Comment #3
kylebrowning commentedDid you clear your cache?
Comment #4
edmeister commentedNow I did. Still the same situation.
Comment #5
RasputinJones commentedSame here.
Comment #6
kylebrowning commentedIm still unable to reproduce, https://skitch.com/kylebrowning/r2nxh/untitled
https://skitch.com/kylebrowning/r2nx6/untitled
Can you give me any more information?
Im using 7.x-3.x dev
Comment #7
RasputinJones commentedHey Kyle. Actually the problem comes before this bit. Ed and I apparently can't even configure the allowed resources for the new service. The error pops up when we try to configure it. I'm going to try to workaround this by downgrading, exporting the settings and reimporting.
Comment #8
RasputinJones commentedBTW. What tool are you using in your screenshot. Looks nifty.
Comment #9
kylebrowning commentedI have figured out a way for it to support sessions, but it gets the job done in most cases.
http://ditchnet.org/httpclient/
Comment #10
RasputinJones commentedEd,
If you haven't figured this out, this workaround should work for you. Fill out the places I pointed out in the file and import it into your site. You can tweak the permissions you want to have as necessary.
Kyle - bugs still there. I tried using xdebug to do some tracing but wasn't so successful. The code's quite unfamiliar to me so can't help much more at this point.
Comment #11
kylebrowning commentedIm not really able to reproduce, can you tell me what your doing step by step?
I can enabled endpoints, I can enable resources, and I can see FULL json.
It sounds like theres two issues and I dont know which one you are still having problems with.
One issue is your seeeing html, and the other is your gettting some error when enabling(maybe?) resources.
Help me help you
Comment #12
RasputinJones commentedSorry, if I've muddled things up for you a bit Kyle. There are two issues. Ed's reported one which is the subject of the thread.
Mine specifically is what he mentioned in #2. I can't seem to see the resources tab after installing Services 7.x-3.x. Rather I get the same error he reported.
This should probably be a separately marked issue.
Ras.
Comment #13
edmeister commentedKyle,
I looked into your headers and noticed you were running PHP 5.2.x. In my different test environments (mamp & vbox ubuntu) I already switched to 5.3. When I switched back to 5.2 in my mamp, everything works well: the resources bug doesn't appear and I can access the rest server.
Rasputin, can you confirm this? Thanks for your import file, btw.
Comment #14
RasputinJones commentedYeah I'm running Zend CE with PHP 5.3. Might be the root cause of it.
Comment #15
edmeister commentedKyle,
I went through the code with Xdebug. When I remove the reference to the $form_state parameter in the services_edit_form_endpoint_resources() function, it is possible to load the resources page.
File: /services/plugins/export_ui/services_ctools_export_ui.class.php
Line: 116
function services_edit_form_endpoint_resources(&$form_state, $endpoint) {Changed to
function services_edit_form_endpoint_resources($form_state, $endpoint) {I did not run any unit tests so I'm not aware if this change breaks any other code.
Comment #16
kylebrowning commentedI dont see anything wrong with removing that, and IM not sure why it was put there in the first place. I just ran all the tests and everything looks good. This has been fixed in both 6.x-3.x and 7.x-3.x, let me know if you have any more issues and feel free to re-open the ticket.
I also updated the title to reflect the actual issue. If the HTML problem persists, please open another ticket.
Comment #17
wedge commentedIs this fix really complete? Wouldn't $endpoint be uninitialized?
To me the services_edit_form_endpoint_resources part of https://github.com/boombatower/services/commit/45825dcd8f07a5b612219f4e9... looks like a better fix to this issue.
Comment #18
mradcliffeI agree with wedge in #17:
Drupal 7 drupal_retrieve_form() expects $form to be passed into the form callback.
If you trace the the arguments being sent in you will find three arguments:
array(), // $form
array('build_info'....), // $form_state
object // $endpoint
With the following patch, I am not even sure $endpoint is relevant anymore, which is why boombatower's patch doesn't include it. Maybe that approach would be better. I'll look into merging what I have now with that and reposting. Just wanted to post what I had come up with separately as well (currently running through tests).
Comment #19
kylebrowning commentedAnything new or should I run the tests on this?
Comment #20
kylebrowning commentedHeres an updated patch. this one needs to be ported to 6.x-3.x
Comment #21
mradcliffeSorry, I have been a bit busy recently focusing on other projects and wasn't able to get back to you, Kyle.
Comment #22
kylebrowning commentedComment #24
christianchristensen commentedThis seems related:I have been working with Services 6.x-3.0-rc1 on PHP 5.3 and the services page shows nothing b/c of a thrown error on variable reference:
file: services_ctools_export_ui.class.php
I noticed a *related* change exists here: https://github.com/boombatower/services/commit/45825dcd8f07a5b612219f4e9...