I have an XMLRPC endpoint set up on my drupal 7 website, with services 3.1, and I have a productive test suite set up in Chrome Poster.

I can call user.login (and subsequently user.logout), and node.create with no problems, but whenever I try to call node.update, I get a "401 Unauthorized" response, (with no body/message).

I have set up permissions for my authenticated user to create and edit ANY content in the system, including the Services permissions (I have now literally ticked every single permission option for them)

Even if, whilst in an authenticated session, I create a node, then confirm it's presence and try to call update on it, I still get a 401 on the POST. If I mess around with the request, I get HTTP 200 - to tell me "Parse error. Request not well formed." and if I remove the "node - update" resource, I get the method doesn't exist message, so everything is genuinely connecting, I just don't appear to be able to grant the permission to edit a node.

Any one else have/had this problem? And any suggestions as to how I can resolve it.
(I'm a fully competent PHP/web developer :) )

Comments

Alessandro Siletto’s picture

Category: support » bug

i thought it was a bug, but inspecting the code i see drupal write 3 cookies during login. you should use only the last one.

here my code to login with Spring RestTemplate

Map<String, String> request = new HashMap<String, String>();
request.put("username", username);
request.put("password", password);
Map<String,Object> result = restTemplate.postForObject(serviceEndpoint+"login.json", request, HashMap.class);	

//save the last cookie with a restTemplate interceptor
//...

Map<String,String> node = new HashMap<String,String>();
node.put("type", type);
node.put("title", title);
restTemplate.postForObject(serviceEndpoint, node,  HashMap.class);
kylebrowning’s picture

Category: bug » support
ygerasimov’s picture

Status: Active » Fixed

@srlawr you need to make sure you do update call properly using PUT request type. Also when you create a node please check whether author of the node is user that you expect logged in. This is ensure that you save your session details properly during your calls.

Anyhow please take a look at node resource tests to see how call are done in php using curl.

Please feel free to reopen this issue if you still have any problems.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.