Using the REST API resources, http://localhost:8095/crowd/rest/usermanagement/latest/user?username=USERNAME
we are able to receive the XML response successfully. The <href> links for <attributes> work without any HTTP error, but not for <password> it produces an HTTP 405 Error code having description :The specified HTTP method is not allowed for the requested resource.
We also tried the http://localhost:8095/crowd/rest/usermanagement/latest/
but got same error.authentication?username=USERNAME
How to access the <password> for authentication purposes from XML response ?
Hi Karthikayan,
The code 405 means that the method used is incorrect. So, maybe, you might be using GET instead of POST, and the password attribute just works with POST method, as you can see in this link in the session User Authentication Resource.
Given that, you can test the command bellow for we see if you can get the return as you expect.
Please let me know if it worked.
Cheers,
Renato Rudnicki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Renato ,
This command worked perfectly on terminal. But produced HTTP 400 error for Content- type :XML.
Also , How can this POST request be embed with PHP-curl script to authenticate a user ?
I am attaching the code snippet for review.
Looking forward to your reply.
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $xml = "<?xml version='1.0' encoding='UTF-8'?>"; $xml .= "<request>"; foreach ($_POST as $key => $val) { $xml .= "<".$key.">". $val ."</".$key.">"; } $xml .= "<username>USERNAME</username>"; $xml .= "<password>PASSWORD</password>"; $xml .= "</request>"; echo "<br/>" . $xml . "<br/><br/>"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost:8095/crowd/rest/usermanagement/latest/authentication?username=USERNAME'); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/xml')); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); $output = curl_exec($ch); curl_close($ch); echo '<pre>'; echo htmlspecialchars(print_r($output, true)); echo '</pre>'; } ?>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You’re welcome Karthikayan, I’m glad that I could help you. Let me try again :) A good way for you do your own troubleshoot about http errors is try to understand what means the HTTP codes. In this case, 400 error means problem with the syntax. You can get a full list in this link: http://en.wikipedia.org/wiki/List_of_HTTP_status_codes . I’m not a developer, but having a look in your php script, I believe that you are in the right way about the code (you just need to find where is the syntax error in your script). However, I’m afraid my PHP skills aren’t enough to help you about the POST request be embed in the script :( but let’s see if someone more can help us with it. If there’s anyone thing that I can do for you, feel free to ask :) Chers, Renato Rudnicki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi karthikayan, I'm glad to hear it :) If you don't mind, could you share the solution here ? Maybe it can be useful to another person in the future. All the best, Renato Rudnicki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Love it when people ask for help and then leave with the comment "I figured solution for this :)". Somehow selfish.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.