asciisd / zoho-v3

Laravel Zoho API V3 Package
MIT License
16 stars 17 forks source link

SDKException while trying to createAsZohoable() #30

Open flavius-constantin opened 6 months ago

flavius-constantin commented 6 months ago

Hey

This is the error i got, when I try to create a User and after that, to run ->createAsZohoable image

I've tried to do the same thing with Tinkerwell and this is the error I became: image

It doesn't matter if I run createAsZohoable() with or without options. The error is still the same.

Here are my Settings out of the .env file:

ZOHO_ACCOUNTS_URL=https://accounts.zoho.eu
ZOHO_API_BASE_URL=www.zohoapis.eu

ZOHO_AUTH_FLOW_TYPE=grantToken
ZOHO_CLIENT_ID="1000.xxx"
ZOHO_CLIENT_SECRET="daxxx"
ZOHO_REDIRECT_URI="${APP_URL}/zoho/oauth2callback"
ZOHO_CURRENT_USER_EMAIL=my@email.com
ZOHO_TOKEN="1000.xxx"

# available datacenters (USDataCenter, EUDataCenter, INDataCenter, CNDataCenter, AUDataCenter)
ZOHO_DATACENTER=EUDataCenter
ZOHO_SANDBOX=false

Please HELP! Thanks!

flavius-constantin commented 6 months ago

The "funny" thing is, that it works on my machine but not on the live Server (Cloud Server, hosted by Hetzner). I use Herd for local development.

I've also created a ZohoAuthenticable File to combine the default Authenticable with Zohoable on the User Model. This is the code:

<?php

namespace App\Traits;

use Asciisd\Zoho\Contracts\Repositories\ZohoableRepository;
use Asciisd\Zoho\Traits\Zohoable as ZohoableModel;
use Asciisd\Zoho\ZohoManager;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\MustVerifyEmail;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\Access\Authorizable;

abstract class ZohoAuthenticable extends Model implements
    ZohoableRepository,
    AuthenticatableContract,
    AuthorizableContract,
    CanResetPasswordContract
{
    use ZohoableModel, Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail;

    protected string $zoho_module_name;
    protected ZohoManager $zoho_module;

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);

        $this->zoho_module = $this->getZohoModule();
    }
}

This is how the method searchCriteria() looks like:

image

And this is the method zohoMandatoryFields():

image
aemaddin commented 6 months ago

Ok, look, you can get more detailed logs from storage/app/zoho/oauth/logs/ZCRMClientLibrary.log

flavius-constantin commented 6 months ago

Same error like in my second image when I've tried to give it a shot through Tinkerwell. Caused by a TYPE ERROR. But, WHY? And what should I do now? As I've mentioned above, it works on my local machine (Laravel Herd) but not on the Live Server hosted by Hetzner.

The Error is clear I think, thank you. But it is very interesting, why it is working on my local machine. I've tried it many times locally and it does what it should. After I've uploaded it to the live server, nothing works. -_-

2024-05-01 10:23:00 com\zoho\api\logger\SDKLogger SEVERE Exception in forming request body :  com\zoho\crm\api\exception\SDKException Caused by : TYPE ERROR - {"field":"leadSource","class":"com\\zoho\\crm\\api\\record\\Record","index":0,"expected-type":"com\\zoho\\crm\\api\\util\\Choice","given-type":"string"}
/home/ploi/d724.de/vendor/zohocrm/php-sdk-6.0/src/com/zoho/crm/api/util/Converter.php- 193- 

2024-05-01 10:27:52 com\zoho\api\logger\SDKLogger SEVERE Exception in forming request body :  com\zoho\crm\api\exception\SDKException Caused by : TYPE ERROR - {"field":"leadStatus","class":"com\\zoho\\crm\\api\\record\\Record","index":0,"expected-type":"com\\zoho\\crm\\api\\util\\Choice","given-type":"string"}
/home/ploi/d724.de/vendor/zohocrm/php-sdk-6.0/src/com/zoho/crm/api/util/Converter.php- 193- 
aemaddin commented 6 months ago

I don’t know exactly what is happening in the live server, but I guess it could be the PHP version may led to the issue

aemaddin commented 6 months ago

Just changing the type of lead source and lead status to Choice instead of string should fix the issue