Hi, I’m using the API via CURL/PHP.
I am trying to query the Pinecone via vector ID.
When I run it in the Dashboard, it works great:
However, when I do it via code, it’s not working. Returns:
string(0) “”
Here is the code: (all of the properties seem to be returning correctly…)
$url = PINECONE_BASE_URL . "query";
$headers = [
"Api-Key: " . $this->pineconeAPIKey,
"Accept: application/json",
"Content-type: application/json"
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'includeValues' => 'true',
'includeMetadata' => 'true',
'id' => 3,
'namespace' => 'my_namespace',
'topK' => 5
]),
CURLOPT_HTTPHEADER => $headers,
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
return $response;
}
}
Thanks in advance for any help!