Twilio\Exceptions\RestException: [HTTP 400] Unable to create record: Cannot CREATE credentials record

Viewed 631

I am getting an error when I try to create a Twilio Push Notification credential using Rest Api for my Subaccount in Twilio , Here is the response :

Twilio\Exceptions\RestException: [HTTP 400] Unable to create record: Cannot CREATE credentials record. 'Secret' must be present in file /home/forge/qc.cp.iocod.com/vendor/twilio/sdk/src/Twilio/Version.php on line 85

My code is

$sub_account = new TwilioClient('ACxxxxxxxxxxxxxxxxxx6f4', '7exxxxxxxxxxxxxxxxxxxx');
if( $sub_account)
{
    $variable = $sub_account->notify->v1->credentials->create([
        "type" => 'fcm',
        "secret" => 'AxxxxI:APA91bG-WY6p9jNuTtgX5SohRF4VviARCjz68FIxvpTIeYUexxxxxxxxx',
  
    ]);
    if( $variable)
    {
        echo $variable->sid;
        
    }
}
2 Answers

Please cross-check your second parameter, the First parameter should be type, and the second parameter should be an array of secret

Finally, I got the solution

$variable = $sub_account->notify->v1->credentials->create('fcm',["secret" =>'Your_FCM_TOKEN',]);
if( $variable)
{
   echo $variable->sid;
}
 

           
Related