Adding a new user (RestApi )

Hey
Tell me how can I add a username and password to the request to add a new user?
POST: http://example.com:9090/plugins/restapi/v1.6.0/users

That’s described with an example in the documentation. In the body of the POST, you’ll need to provide an XML snippet, like so:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<user>
    <username>test3</username>
    <password>p4ssword</password>
</user>

I mean HTTP basic auth - REST API authentication with Openfire admin account.
How exactly, sample code is desirable.
Thank you.

This too is defined in the documentation: you can use either a shared secret, or basic authentication.

httpClient.setRequestProperty(“username”,“admin”)
httpClient.setRequestProperty(“password”,“admin”)

It doesn’t work, how right?

I’m sorry, that’s a question for the authors of the authors of the web library that you’re using.

In this code, I add properties to the request, but I need to insert them into the request header, in which one?

I figured out that I need to add httpClient.setRequestProperty (“Authorization”, “Basic” + Base64.encodeToString (“admin: admin” .toByteArray (), Base64.NO_WRAP)), but now a 404 error appears, although I send {“users”: [{“username”: “bob”, “password”: “12345”}]} at http://example.com:9090/plugins/restapi/v1.6.0/users.

I get the error failed to open stream: HTTP request failed! HTTP / 1.1 404 Not Found
What am I doing wrong?

The restapi directory should have a v1.6.0 directory and a users? I do not have them.

Correct request http://example.com:9090/plugins/restAPI/v1.6.0/users, not restapi, but restAPI. There is no 404 error anymore, but there is a 302 error, can anyone know why?