Login (POST)
POST /alfresco/service/api/login
—
Login and establish a ticket.
Input
JSON Data Object.
username
cleartext username
password
cleartext password
Returns the new authentication ticket.
…
strUri = "http://localhost:8080/alfresco/service/api/login";
strJson = @"[""username"", ""admin"", ""password"", ""contacts""]";
// Create the Web Request Object
WebRequest request = WebRequest.Create(strUri);
// Specify that you want to POST data
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
if (strUri != null)
{
// write out the data to the web server
writeToURL(request, strJson);
}
else
{
request.ContentLength = 0;
}
// read the response from the Web Server
strHtmlContent = retrieveFromURL(request); //Das Lesen der Antwort ergibt einen Fehler
….
private String retrieveFromURL(WebRequest request)
{
// 1. Get the Web Response Object from the request
WebResponse response = request.GetResponse();
// 2. Get the Stream Object from the response
Stream responseStream = response.GetResponseStream();
// 3. Create a stream reader and associate it with the stream object
StreamReader reader = new StreamReader(responseStream);
// 4. read the entire stream
return reader.ReadToEnd();
}// end retrieveFromURL method
Leider gibt es hier immer den Fehler 404, 'Bad request' sobald ich versuche die Antwort zu lesen. Der Fehler tritt auf in der Funktion retrieveFromURL in der ersten Zeile.
//anstatt strJson = @"[""username"", ""admin"", ""password"", ""contacts""]";
strJson = "{username: \"admin\", password: \"contact\"}"; //wenn contacts dein PW ist
//anstatt request.ContentType = "application/x-www-form-urlencoded";
request.ContentType = "application/json";
VG, Jan
curl http://localhost:8080/alfresco/service/api/login -H "content-type: application/json" -d "{username: \"admin\", password: \"contacts\"}"
–> sowas wie
{
"data":
{
"ticket":"TICKET_6c3ba5ca3b72872b7ddbe8bcde9cca86f36af08c"
}
}
Archive content from product discussions in German.
This group is now closed and content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.