Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDKException while trying to createAsZohoable() #30

Open
flavius-constantin opened this issue Apr 30, 2024 · 5 comments
Open

SDKException while trying to createAsZohoable() #30

flavius-constantin opened this issue Apr 30, 2024 · 5 comments

Comments

@flavius-constantin
Copy link

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"
[email protected]
ZOHO_TOKEN="1000.xxx"

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

Please HELP!
Thanks!

@flavius-constantin
Copy link
Author

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
Copy link
Contributor

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

@flavius-constantin
Copy link
Author

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
Copy link
Contributor

aemaddin commented May 1, 2024

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
Copy link
Contributor

aemaddin commented May 1, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants