Blocking user via API, returns 404

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?

1 Like

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.

4 Likes

Can we update these docs @blake?

3 Likes

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?

Done.

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

5 Likes

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?

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

3 Likes

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

2 Likes

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

3 Likes