Mautic Community Forums

Getting Error 404 with campaigns API

Hello,

We are getting an error when fetching campaigns list using API from 404 using below code

use Mautic\MauticApi;
use Mautic\Auth\ApiAuth;
$settings = array(
‘baseUrl’ => ‘https://mautic.ethlyte.tech’,
‘version’ => ‘OAuth1a’,
‘clientKey’ => ‘594fwpwhsgkc0wwsgc84kokgksocgc40w40800oswkcs0gwkg4’,
‘clientSecret’ => ‘62d81xnnyfkso4g8okgg888sokogkgoosgk00ko8g8888sg4k0’,
‘callback’ => ‘https://app.upviral.com/utility/mautic_config.php’,
‘accessToken’ =>‘3vmote72ua80c8ooc4co04w8s804o8o8w8cc0kwkw84sswwwss’,
‘accessTokenSecret’ =>‘4nk0ozbpebok8w8k04cs4ks8skoog8k4g00g4g8g80c4wkwc84’
);

$initAuth = new ApiAuth();
$auth = $initAuth->newAuth($settings);
$apiUrl = $getIntegrationDetails->api_id;
$api = new MauticApi();

//Campaign
$campaignApi = $api->newApi(“campaigns”, $auth, $apiUrl);
$campaigns = $campaignApi->getList();
echo “

”;
print_r($campaigns);
die;

Above code return below output

Array ( [errors] => Array ( [0] => Array ( [message] => Looks like I encountered an error (error #404). If I do it again, please report me to the system administrator! [code] => 404 [type] => ) ) [error] => Array ( [message] => Looks like I encountered an error (error #404). If I do it again, please report me to the system administrator! (error is deprecated as of 2.6.0 and will be removed in 3.0. Use the errors array instead.) [code] => 404 ) )

We have followed the API doc https://developer.mautic.org/#list-campaigns.

How can we fix this error?