Page 1 of 1

API function to just test the connection and see if NZB key is correct?

Posted: August 12th, 2020, 4:06 am
by Tensai
Hi

I am the programmer of NZBDonkey which interacts with Sabnzbd via its API. As far as I know, there is no dedicated API function to just check the connection and see if the NZB key (or API key) is correct. Until version 2.3.9 I somehow misused the addurl function by sending an empty name which nevertheless resulted in status=true (and simply an empty array for the nzo_ids). With version 3.0.0 this has changed and Sabnzbd returns status=false and error="expects one parameter".

I therefore wonder which would be the proposed/best way to test the API connectivity with an NZB key (without actually doing anything to the settings, queue, etc.) which will result in a status=true response?

Looking forward to your help/suggestions.

Regards, Tensai

Re: API function to just test the connection and see if NZB key is correct?

Posted: August 12th, 2020, 4:12 am
by safihre
You can still use it :)
The API-key check is performed before the "expects one parameter" check. So if you get "expects one parameter", the API/NZB-key is correct.

Re: API function to just test the connection and see if NZB key is correct?

Posted: August 12th, 2020, 4:19 am
by Tensai
Ok. Thanks for this info.

However, can I then count on it that the error message will always remain "expects one parameter" upon this API call with an empty name argument?
Because I will have to check for this error message explicitly to distinguish it from other errors.

In any case, a dedicated API function for the purpose of testing the NZB/API key (resulting in status=true) would be much more convenient.

Regards, Tensai

Re: API function to just test the connection and see if NZB key is correct?

Posted: August 12th, 2020, 4:26 am
by safihre
If the API key is incorrect, it will give "API-key incorrect". So when it's not that, it should be good.
We don't have such a status-API and right now and don't see the exact need for it right now.
As we have also 5 different API-levels (for internal/external/non-NZB/etc), it would be an API that has to support all these checks.

Re: API function to just test the connection and see if NZB key is correct?

Posted: August 12th, 2020, 4:51 am
by Tensai
Ok, I'll work with what I get and implement an error check ;)

However, such a "access test" API endpoint would only be needed for external API access and simply needs to return status=true (or false) after key check is done.
Should be a pretty simple thing to implement.
And the need is definitely there. It is always beneficial for the user to have the possibility to test credentials/connectivity already in the settings instead of encounter the errors later when using the application. Therefore my Add-on gives the possibility to check the connection to Sabnzbd (and also the other supported programs) within the settings page. Other Apps do this similarly. And for this purpose an API endpoint is needed which checks the key but does not perform any other action.

Anyway, thanks for the help!

Tensai