Create users using rest-api

After changing the url to http://forums.my-domain.net/users instead of .json I get http “204 no content” back.

When creating the api key I don’t see the create route in granular mode. So I’ve set it to global. Perhaps the issue is indeed that I don’t have permission. Do I need to create the key as system user? Currently I am using the admin user with “Discourse Admin” group


const data = create = {
    name: "TestName",
    email: "test@mydomain.com",
    password: "TestTestTest",
    username: "TestUsername",
    active: true,
    approved: true,
    "user_fields[1]": true,
    external_ids: {
      uuid: "some uuid",
    },
};
//URLSearchParams is the same as FormData
const formData = new URLSearchParams();
for (const key in data) {
  formData.append(key, data[key]);
}

const url = BASE_URL + "users";
const response = await fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/x-www-form-urlencoded",
     Accept: "application/json",
     "Api-Key": API_KEY,
     "Api-Username": API_USER,
  },
  body: formData,
 });

console.log("Response: " + response.status + ": " + response.statusText);

Perhaps you could show me the command/code you use to send the request? @JammyDodger