@brittle bramble You've just shared your API key, so anyone can now access your account and do any action the key allows. I'd really suggest taking a look at some best practices first, like storing credentials in an .env file and then accessing it through config (https://laravel.com/docs/10.x/configuration). That way your credentials won't end up in git history and you won't (accidentally) share your private keys with the world.
#Need help in Tawk.to API
26 messages · Page 1 of 1 (latest)
#1085457875595431966 message
You mentioned you were using POST method, but nothing has changed.
Ah, nice, the key was already shared earlier
My key now
@brittle bramble I'll remove your posts unless you update both posts and remove the key. Not that that would have much of an effect, because key has probably already been saved by others. So, revoke the key and store your credentials properly
#general message
#1085457875595431966 message
told him to remove the key, but he is fine with that.
Alright, well they're unresponsive. Best course of action is to delete the posts 
Thanks for linking those 🙂
sorry, I was away
np, just trying to be part of the community 😉
How can I edit my post now?
Right click it and then "Edit message"
Here is my updated laravel controller code :
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use GuzzleHttp\Client;
class KB extends Controller
{
public function getKnowledgebaseArticles()
{
$client = new Client([
'base_uri' => 'https://api.tawk.to/v1/knowledge-base.category.list-article',
'headers' => [
'Authorization' => 'Bearer API_KEY',
'Content-Type' => 'application/json',
'Accept' => 'application/json'
]
]);
$response = $client->request('POST', 'knowledge-base.list-article');
if ($response->getStatusCode() == 200
) {
$data = json_decode($response->getBody(), true);
$articles = $data['articles'];
dd($articles);
} else {
// Handle the error
}
}
}
@terse dagger
showing this error : Client error: POST https://api.tawk.to/v1/knowledge-base.list-article resulted in a 404 Not Found response: {"ok":false,"error":"not_found"}
Well that URI is different to the one in your code, so please show us your actual code (with the API key omitted obviously).
Here is my actual laravel controller code :
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use GuzzleHttp\Client;
class KB extends Controller
{
public function getKnowledgebaseArticles()
{
$client = new Client([
'base_uri' => 'https://api.tawk.to/v1/',
'headers' => [
'Authorization' => 'Bearer API_KEY',
'Content-Type' => 'application/json',
'Accept' => 'application/json'
]
]);
$response = $client->request('POST', 'knowledge-base.list-article');
if ($response->getStatusCode() == 200
) {
$data = json_decode($response->getBody(), true);
$articles = $data['articles'];
dd($articles);
} else {
// Handle the error
}
}
}
I have removed the api_key.
You’re using Guzzle. If the request isn’t successful, an exception will be thrown. You don’t need to check the status code in an if/else block like that.
So what’s the full error you get with the above code?
Client error: POST https://api.tawk.to/v1/knowledge-base.list-article resulted in a 404 Not Found response: {"ok":false,"error":"not_found"}
So, the URL you're requesting isn't found, check the docs if you're using the correct URL
Yeah. I mean, you’re getting a 404. From a server. Which means you’re requesting a URL that doesn’t exist. So is that path correct? Are they really uses dots in a URI like that? Because I’d be surprised if they were.
Please check the doc.
please remove the credentials
again you are not sending the required parameters. So I guess that is the issue.