rhijjawi/NextDNS-API

[URGENT Bug] Library has stopped working. {'errors': [{'code': 'notFound'}]} for profiles that exist

ishan opened this issue · 7 comments

ishan commented

Describe the bug
The library has suddenly stopped working for me.

To Reproduce

  1. Authenticate header = account.login(USERNAME, PASSWORD, totp_code)
  2. Try any operation, like add to denylist, using this header. eg. denylist.blockdomain(domain, "abcdef", header)

Expected behavior
The domain should be added to the denylist.

Observed behavior
The call fails with code 'notFound'. This happens for all API methods and started happening suddenly in the last 2 days.

Yes, I can confirm that for me too.

They seem to have adjusted the API what was configurations before is now profiles and there are other changes.
https://nextdns.github.io/api/#profiles

The correct code to add a domain to the deny list is now:

import requests

API_KEY = "YOUR_API_CODE" # Find your API key at the bottom of your account page (https://my.nextdns.io/account)
config = "YOUR_CONFIG_ID"


def main():
    header = {"X-Api-Key": API_KEY, "Content-Type": "application/json"}
    apiurl = f"https://api.nextdns.io/profiles/{config}/denylist"
    domain = '{"id": "nextdns-api-test.com"}'

    # Add domain to deny list
    requests.post(url=apiurl, headers=header, data=domain)

    # Print domains from deny list
    print(requests.get(headers=header, url=apiurl).json())


if __name__ == "__main__":
    main()

Thanks everyone, I'll get to work rewriting the lib ;)

ishan commented

I tested denylist.blockdomain on @hagezi's branch and it is working as expected.

Thanks @hagezi for the PR!

i am having the same issue again now

Have you updated the library since this issue?