Hi Gerard,
I’m glad you found a workaround! I am curious, though, about the trouble you were having with username/password authentication.
When using the API, you do have to send the credentials with each request, whether you’re using username/password or token authentication. By contrast, a web browser perusing the API creates a session the first time you log in, where authentication details are stored in cookies etc., saving you the hassle of logging in again every time you load a different page.
I don’t have a VBA environment handy, but here’s a test using the program “curl” and an account whose username is “apitest” and password is “the password”:
You’re right that an unauthenticated request leads to the “Not found” error you received, e.g.
$ curl https://kc.kobotoolbox.org/api/v1/data/55576
{"detail":“Not found.”}
The maintainer of the software library responsible for that behavior discusses his rationale at https://github.com/tomchristie/django-rest-framework/issues/1439#issuecomment-36012573.
Still, what’s curious to me is that your request:
Call httpReq.Open(“GET”, “https://kc.kobotoolbox.org/api/v1/data/55229”, False, “my_userid”, “my_password”)
…does specify the username and password, and yet it still failed. If that continues to happen, please let us know so that we can investigate further.
Thanks,
John Milner
Developer, KoBoToolbox
I didn't find a solution for the problem, but I've found a work around by
using token authentication.
I'm now able to get the dataset.
In case someone runs into the same issue, a simplified version of the VBA
code below:
Dim httpReq As New MSXML2.ServerXMLHTTP60
Call httpReq.Open("GET",
"https://kc.humanitarianresponse.info/api/v1/data/67602?format=xml", False)
httpReq.setRequestHeader "Authorization", "Token <all the digits of my
secret token>"
httpReq.send
Debug.Print httpReq.responseText
--
You received this message because you are subscribed to the Google Groups "Kobo Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.
To post to this group, send email to kobo-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kobo-users.
For more options, visit https://groups.google.com/d/optout.