Discussions

Ask a Question
Back to All

I am getting error, while deleting old connection.

First, I authorize with moneyhub test bank and choose 3 accounts and all after authorization, I got the authorization_code and all accounts which i saved to my database, and also i saved the connection id. Now I want to again connect with same bank and wnat to choose 2 accounts, so i want to delete previous connection and want to create new connection, but not everytime, but some times I am getting this error. when I getting this error, then I do not get the accounts which i selected when I again connect with same account. I get the previous connection accounts. Please let me know what should I do for this.
DELETE https:\/\/identity.moneyhub.co.uk\/users\/667410c49e533b138141676e\/connections\/1ffe704d39629a929c8e293880fb449a:4d41a24d-a48b-4886-8262-beb23a83f086 resulted in a 404 Not Found response:"

This is my callback function code which I am using

$old_connection_id = $customParams->old_connection_id ?? "";

$postData = array(
'grant_type' => 'authorization_code',
'code' => $_GET['code'],
'redirect_uri' => $this->MoneyCallBack,
'client_id' => $this->clientId,
'client_assertion' => $token,
'client_assertion_type' => $this->ClientAssertionType,
'sub' => $moneyhub_userid,
);
$client = new Client();
$response = $client->request('POST', $this->tokenUrl, [
'form_params' => $postData
]);
$result = json_decode($response->getBody(), true);
$idToken = $result['id_token'];
list($header, $payload, $signature) = explode('.', $idToken);
// Decode the JSON components of the header and payload
$headerData = json_decode(base64_decode($header));
$payloadData = json_decode(base64_decode($payload));
$signatureData = json_decode(base64_decode($signature));
$moneyhub_connection_id = $payloadData->{'mh:con_id'};


try {
Log::info('old connection id User connection:' . json_encode($old_connection_id));
$this->deleteUserConnection($moneyhub_userid, $old_connection_id);
} catch (Exception $e) {
$errorMessage = explode("\n", $e->getMessage())[0];
Log::error('Error Deleting User connection:' . json_encode($errorMessage));
}

Please let me know what should i do