You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2018-08-10 01:18:06

VampireHunter
Guest
Registered: 2018-08-10
Posts: 1

rest API - Create user

Hi
i try to create new user by rest API
but i have an issue with user password

user created successfully but a can't login into a portal before setting password in administration console

Imports System.Net
Imports System.IO
Imports System.xml
Imports System.xml.linq
Imports System.Xml.XmlDocument
Imports System.Xml.XPath
Imports	Newtonsoft.Json.dll

Public Class JsonGLPIUser
    Public input As GLPIUser
End Class

Public Class GLPIUser
    Public name As String
	Public password As String
	Public firstname As String
    Public realname As String
	Public emails As String
End Class

Public Function gpli_additem (ByVal login As String) As String
Dim uri As String = "https://localhost/glpi/apirest.php/user"
Dim request2 As HttpWebRequest = CType(WebRequest.Create(uri), HttpWebRequest)
request2.Method = "post"
request2.ContentType = "application/json"
request2.Headers("App-Token") = "Sa1hSIAEh4gyiiefJlpbYmAfL3iQEp9sg6lO8l3P"
request2.Headers("Session-Token") = glpi_init()
Dim jsonglpiuser As JsonGLPIUser = New JsonGLPIUser()
Dim newuser As GLPIUser = New GLPIUser()
newuser.name = login
newuser.firstname = "firstname"
newuser.realname = "lastname"
newuser.password = "P@ssw0rd"
newuser.emails = login + "@mail.com"
JsonGLPIUser.input = newuser
Dim jsonglpiuserConverted As String = JsonConvert.SerializeObject(JsonGLPIUser) 
Dim userstring As String = jsonglpiuserConverted
Dim postdatabytes As Byte()
postdatabytes = Encoding.UTF8.GetBytes(userstring)
Request2.ContentLength = postdatabytes.Length

Using stream = Request2.GetRequestStream()
    stream.Write(postdatabytes, 0, postdatabytes.Length)
End Using

End Function

can't find a problem with setting password for user

Offline

#2 2018-08-22 19:34:42

KKAdmin
Guest
From: Germany
Registered: 2010-03-05
Posts: 866

Re: rest API - Create user

I believe you can find the solution in this tracker https://github.com/glpi-project/glpi/issues


You can mark this threat as [resolved] in subject of your threat. (This is only available edit of the first post.) It is good for users who help others to quickly see which post is still open.
##############################################
GLPI 9.2.3 /Ubuntu 16.04.4 LTS
Apache/2.4.18 (Ubuntu) - PHP 7.0.30-0ubuntu0.16.04.1 - MySQL 5.7.22-0ubuntu0.16.04.1

Offline

Board footer

Powered by FluxBB