How does one change a username via the API?


(jezra) #1

While using the API and making a put request to:
MYDISCOURSE/users/MYUSER?api_key=MYSYSTEMAPIKEY&api_username=system
with a json payload of:
{“username”:“helloworld”}
I am receiving a response with a code of 200 and a body that indicates the username has not been changed.


(Blake Erickson) #2

Try this endpoint instead:

curl -i -sS -X PUT "http://127.0.0.1:3000/u/blake/preferences/username.json"  \
-H "Content-Type: multipart/form-data;" \
-F "api_key=a66d01fbe98cc51b2747d8bfe99f81d7adca18317fbf3c43aa20f340d8e25bfe"  \
-F "api_username=system" \
-F "new_username=blake2"

And it will output:

{"id":1,"username":"blake2"}

#4

I was wondering: is it safe to change the system username?


#5

Looks like this is not confirmed yet.


(jezra) #6

Thank you @blake that was exactly what I needed. :slight_smile: