Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Receiving this error when trying to add a new user on the remote site. Where should user_raw come from?
Comment | File | Size | Author |
---|---|---|---|
#12 | 1728992-wrong-rest-http_method-assignment.patch | 1.31 KB | mhrabovcin |
Comments
Comment #1
mhrabovcin CreditAttribution: mhrabovcin commentedHello,
here is my sandbox project that provides these resources - http://drupal.org/sandbox/mhrabovcin/1424044 please note that this is bypassing any drupal validation and raw data are saved only via API functions like user_save.
Martin
Comment #2
Nick_vhThis is included in the project now. So i think we can close this one
Comment #4
jpstrikesback CreditAttribution: jpstrikesback commentedI'm seeing this with services_raw installed, very odd. I've tried upping it's module weight, a lite refactor (moved methods into a .resource.inc file and the services_resources implementation back into the .module) no dice.
Debug:
ServicesException::__set_state(array(
'data' => 'Could not find resource node_raw.',
'message' => 'Could not find resource node_raw.',
'string' => '',
'code' => 404,
'file' => '/srv/bindings/.../code/sites/all/modules/services/services.runtime.inc',
'line' => 355,
'trace' =>
array (
0 =>
array (
'file' => '/srv/bindings/.../code/sites/all/modules/services/servers/rest_server/includes/RESTServer.inc',
'line' => 76,
'function' => 'services_error',
'args' =>
array (
0 => 'Could not find resource node_raw.',
1 => 404,
),
),
1 =>
array (
'file' => '/srv/bindings/.../code/sites/all/modules/services/servers/rest_server/rest_server.module',
'line' => 34,
'function' => 'handle',
'class' => 'RESTServer',
'type' => '->',
'args' =>
array (
0 => 'node_raw/create',
1 => 'endpoint',
Comment #5
mhrabovcin CreditAttribution: mhrabovcin commentedCan you export your services endpoint settings?
Comment #6
jpstrikesback CreditAttribution: jpstrikesback commentedHere we are:
Comment #7
mhrabovcin CreditAttribution: mhrabovcin commentedI see the problem, you have aliased your node_raw resource to rawnode
'alias' => 'rawnode',
Comment #8
jpstrikesback CreditAttribution: jpstrikesback commentedWith or without Alias I still get the same 404 unfortunately...(I mean with the alias in the config and visiting either the endpoint or the aliased endpoint, and also without the alias in the resource config)
Comment #9
jpstrikesback CreditAttribution: jpstrikesback commentedOK, I've played with the endpoint a little more:
GET = 404
POST = 404
PUT = 401 :) so it wants a PUT, all my node_raw/create requests from services client are sent as POST, is that correct?
Comment #10
jpstrikesback CreditAttribution: jpstrikesback commentedOK I believe I have found the issue after learning a little about services, etc...
Services is expecting a POST with no path arguments to initiate the create action.
Because ServicesClientConnectionHttpRequest->http_method defaults to 'GET' ServicesClientConnectionRestServer::prepareRequest() always skips over the special REST CRUD actions as that block has
if (empty($request->http_method)
as it's first condition, and it is (AFAIK) never empty at this point since the default is 'GET'. Then it moves on and eventually appends /create to the url, sends a POST and RESTServer has no idea what to do with this.Comment #11
mhrabovcin CreditAttribution: mhrabovcin commentedComment #12
mhrabovcin CreditAttribution: mhrabovcin commentedI've added patch which fixes the problem and added better comments for decision logic in REST plugin.
Comment #13
mhrabovcin CreditAttribution: mhrabovcin commentedComment #14
Nick_vhyou can add !empty() here and then resort to elseif without condition?
Comment #15
mhrabovcin CreditAttribution: mhrabovcin commentedhttp_method is always initialized by default to 'GET'. Committed to repo.
Comment #16
jpstrikesback CreditAttribution: jpstrikesback commentedExcellent, thanks!