You are not logged in.


 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

Registered: 2018-08-10
Posts: 1

rest API - Create user

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() = login
newuser.firstname = "firstname"
newuser.realname = "lastname"
newuser.password = "P@ssw0rd"
newuser.emails = login + ""
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


Board footer

Powered by FluxBB