arthur-shaw / susoapi

R interface for Survey Solutions' APIs
https://arthur-shaw.github.io/susoapi/
Other
9 stars 5 forks source link

Trouble with validating api credentials #45

Closed SamHarsha closed 5 months ago

SamHarsha commented 5 months ago

[Pasting the issue here from Survey Solutions Forum. Apologies for the late reply} Hello, I have created an api user from our admin account for our survey solutions server. Using this susoapi R package, I have set the credentials. set_credentials( server = “http://0.0.0.1/*...**/”, workspace = “XXX”, user = “xyz_api”, password = “xyz1” ) When I check credentials, it says “Credentials invalid for workspace XXX.”

However, when I run get_workspace function using GUID for the xyz_api user, it gives XXX workspace in the list. The credentials are correct, yet I am not able to access any data.

I also created another API user xyz_api1 account to check. When I set credentials using xyz_api1 details, it is giving me the same error. Not only that, I am not even able to run the ‘get_workspaces’ function with this user. It gives following error:

Error in value[[3L]](): ! No workspaces found. [UPDATE: When I tried today, I am getting the XXX workspace in the list]

I am new to both R and APIs in general so it may be that I am missing something obvious, but I would appreciate any help nonetheless.

To reply to queries raised on the forum: I am using 22.09.1 (build 33151) version. Both xyz_api and xyz_api1 are API user IDs. I am correctly using workspace name, as opposed to the display name.

arthur-shaw commented 5 months ago

Since I see that you set credentials like this:

set_credentials( server = “http://0.0.0.1/*...**/”, workspace = “XXX”, user = “xyz_api”, password = “xyz1” )

In particular I see server = “http://0.0.0.1/*...**/”, where the URL has a terminal slash.

Based on that observation, I wonder if the problem could be fixed simply by specifying the URL without a terminal slash (e.g., server = “http://0.0.0.1/*...**”).

If that's the case, this is my fault, not yours. Indeed, I have a pull request to address this issue, but haven't yet done the testing before merging it.

Does that resolve your issue?

SamHarsha commented 5 months ago

Oh My God, that did work! I cannot believe it was that simple! Thank you for your quick reply