Hi,
I'm trying to make an API call to add data to a custom view in Leads scope. I'm getting grant token, refresh token and access token successfully with help of curl call and than PHP SDK. My problem is when I want to get Leads fields I get 'invalid oauth token' message. My user has restricted access, I only see the custom view in top navigation when accessing ZohoCRM with my user.
Code I'm trying to use to retrieve field values is:
- $config = [
- 'client_id' => $clientId,
- 'client_secret' => $clientSecret,
- 'redirect_uri' => $redirectUri,
- 'currentUserEmail' => $userEmailId,
- 'applicationLogFilePath' => $this->applicationLogFilePath,
- 'token_persistence_path' => $this->tokenPersistencePath,
- 'accounts_url' => $this->accountsUrl
- ];
- \ZCRMRestClient::initialize($config);
- $zcrmIns = \ZCRMRestClient::getInstance();
- $zcrmAPIResponse = $zcrmIns->getModule('Leads');
- $zcrmModule = $zcrmAPIResponse->getData();
- $zcrmFields = $zcrmModule->getAllFields()->getData();
Code I'm trying to use to insert new record is:
- \ZCRMRestClient::initialize($config);
- $record=\ZCRMRecord::getInstance('Leads',null);
- foreach ($data as $item => $value) {
- $record->setFieldValue($item, $value);
- }
- $zcrmModuleIns = \ZCRMModule::getInstance('Leads');
- $bulkAPIResponse = $zcrmModuleIns->upsertRecords([$record]);
- $entityResponses = $bulkAPIResponse->getEntityResponses();
This code works by the way if I'm trying it with a newly created ZohoCRM test account created by me and with the plain 'Leads' scope but with real user to real client I have restricted access only to see custom view of 'Leads'.
Can you please help me with this somehow? I realy need to solve this somehow.
Thanks.
Best regards.