Jump to content

Featured Replies

Posted

Ok, so I am working with API to get recent posts. I do have an API key and all set up. I need to access this endpoint: /api/forums/topics?key={API_KEY}&forums=16,23,27,28,81&sortBy=updated&sortDir=desc&perPage=100

When I manually visit this page I get proper JSON response. When I do try to access it via python script I do get 403 error but there is no log on API log in admin panel.

Code:

def make_request(url):
    headers = {
        'User-Agent': 'MyUserAgent/1.0',
        'X-Authorization': f"Basic {API_KEY}"  # Alt: base64.b64encode(f"{API_KEY}:".encode()).decode()
    }
    params = {
        'key': API_KEY
    }
    print(url)
    response = requests.get(url)
    print(response)
    return response

And prints:

https://forum.MY_FORUM/api/forums/topics?forums=16,23,27,28,81&sortBy=updated&sortDir=desc&perPage=100
<Response [403]>

Again, after manually copying url from above I do get proper JSON response. The weirdest part is - it used to work for some time and stopped with no reason, no change in code.

API Logs shows no entry with 403 code:

obraz.png

Please help?

The first thing I notice there is the lack of a proper user agent string. Try corrected that, and if you are still having issues, if you can create a ticket and send me the ip that is calling this, I can take a look to see if I can see what is blocking it

Recently Browsing 0

  • No registered users viewing this page.