Blocking user via API, returns 404


(Thomas K. Running) #1

Hi guys, I’m trying to block a user via the API as documented here (PUT to /admin/users/ID/block), but just getting a 404 in return.

> PUT /admin/users/2238/block?api_key=REDACTED&api_username=REDACTED HTTP/1.1
> Host: REDACTED
> User-Agent: insomnia/5.16.6
> Content-Type: application/json
> Accept: */*
> Content-Length: 2
| {}


< HTTP/1.1 404 Not Found
< Server: nginx`
< Date: Sat, 21 Jul 2018 07:53:34 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Vary: Accept-Encoding
< X-Request-Id: 3d46b5fd-d23d-4479-bc09-948e4065abad
< X-Runtime: 0.047682

Any idea what’s going on?


#2

I’m afraid the doc’s a bit outdated:

block has been renamed to silence Discourse-wide, and the new endpoint should be /admin/users/:id/silence.


(Jeff Atwood) #3

Can we update these docs @blake?


(Thomas K. Running) #4

Ok, thanks guys.

What I’m really trying to do is banning that user/email/IP (typically a kind of spammer who puts spam in their name and/or profile information, so akismet isn’t helpful, nor restrictions on posting for new users), similar to if I clicked the “Delete and block this email and IP address” button.

Is that possible to do via the API as well?


(Blake Erickson) #5

Done.

Yes you can use this endpoint and pass the appropriate params.


(Thomas K. Running) #6

For some reason I’m getting a 404 using that endpoint as well. Perhaps I’m not authenticating correctly or something… Here’s my request:

Any idea why I’m getting a 404 now?


(Blake Erickson) #7

Looks like your content type is set to “application/json”. It needs to be “multipart/form-data”.


(Jeff Atwood) #8

Can we make sure this is prominent in the docs as I have seen it come up multiple times now?


(Blake Erickson) #9

Done. I updated https://docs.discourse.org and the api page on meta.