I’m toying about with writing a client in Rust.
Example code online uses the API endpoint https://lemmy.ml/api/v3/post/list
, and when I go to this link in a browser, it doe indeed load data. However, when I try to load it from a program, it gives me a 403 Forbidden
. Does anyone know why this could be?
(code)
This one got me too.
lemmy.ml specifically is running requests through a user agent checker - and if it’s empty, which reqwest is by default, you will get a 403.
You can see an example here of using ClientBuilder to set a user agent string: https://github.com/CMahaff/lasim/blob/main/src/lemmy/api.rs
So set any string (should be your project name) and then it should work.
Oh great thank you