Hello,
I’m trying to upgrade my PHP application to the v2 API and can’t even get it to respond back to me at all.
V1 Code that Works:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://kc.kobotoolbox.org/api/v1/data/'.$projectId);
curl_setopt($curl, CURLOPT_USERPWD, $this->user.":".$this->pw);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$resp = curl_exec($curl);
Results in the following curl request/response:
Request: GET /api/v1/data/<projectid> HTTP/2 Host: kc.kobotoolbox.org
Response: {"detail":"Not found."}
Now, updated for V2 no matter the endpoint I try to use I cannot get a response from Kobo:
Here’s an example:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://kc.kobotoolbox.org/api/v2/assets.json');
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Accept: application/json","Authorization: ".$this->token));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$resp = curl_exec($curl);
This results in a Request/Response as follows:
Request: GET /api/v2/assets.json HTTP/2 Host: kc.kobotoolbox.org accept: application/json authorization: <mytoken>
Response: No Data
I’ve also tried V2 with Basic HTTP Auth and many variations of the endpoint and I cannot get any response at all.
What am I doing wrong here? Thanks in advance for any assistance.