I am having a problem with my Zoho Laravel Integration.
我的Zoho Laravel集成有问题。
Using the Merge and Sign scope, I cannot fix the merge_data of the ZOHO API.
使用Merge and Sign作用域,我无法修复Zoho API的merge_data。
This is the documentation of ZOHO Merge and API: https://www.zoho.com/writer/help/api/v1/merge-and-sign.html
以下是Zoho合并和接口:https://www.zoho.com/writer/help/api/v1/merge-and-sign.html的文档
public function SendWaiver()
{
$accessToken = $this->getAccessToken();
\Log::info('Access Token: ' . $accessToken['access_token']);
$response = Http::withHeaders([
'Authorization' => 'Zoho-oauthtoken ' . $accessToken['access_token'],
'Content-Type' => 'application/json'
])
->post('https://writer.zoho.com/api/v1/documents/kcrsoa321953c62f54fadba97ee1b525ef8c4/merge/sign', [
'service_name' => 'zohosign',
'filename' => 'Under Age Waiver',
'signer_data' => json_encode([
'recipient_1' => '[email protected]',
'action_type' => 'sign',
'language' => 'en'
]),
'merge_data' => json_encode([
'data' => [
[
' Gym_Name' => 'Gym1',
' Member_Name' => 'Ryle Traya',
' Parent_Name' => 'Rommel Traya',
' Contact_Phone_Number' => '09771054119'
]
]
])
]);
\Log::info('Merge Data : ' . json_encode([
'data' => [
[
'Gym_Name' => 'Gym1',
'Member_Name' => 'Ryle Traya',
'Parent_Name' => 'Rommel Traya',
'Contact_Phone_Number' => '09771054119'
]
]
]));
return response()->json($response->json(), $response->status());
}
And the output is:
输出结果为:
{
"error_collection": [
{
"message": "Merge data not found. Please try again with proper merge data.",
"documentation_url": "https://www.zoho.com/writer/help/api/v1/merge-api-possible-error-codes.html",
"errorcode": "R6001"
}
],
"error": {
"message": "Merge data not found. Please try again with proper merge data.",
"documentation_url": "https://www.zoho.com/writer/help/api/v1/merge-api-possible-error-codes.html",
"response_generated_time": 1694411379849,
"request_url": "https://writer.zoho.com/api/v1/documents/kcrsoa321953c62f54fadba97ee1b525ef8c4/merge/sign",
"errorcode": "R6001"
}
}
But in my logs, the output is jsonly correct.
但在我的日志中,输出只有jsonly正确。
Help me with this.
帮我弄一下这个。
I tried json_encode
, I tried laravel 9 array. And my expectation is that my API Integration of Merge and Sign will be success since I am following the documentation
我试过json_encode,我试过laravel 9 array。我的期望是,我的API合并和签名集成将是成功的,因为我遵循的文档
更多回答
优秀答案推荐
I am not sure, but I could suspect the below two cases:
我不确定,但我可以怀疑以下两种情况:
Space character in Merge data keys:
There is a space at the start of the keys in merge_data
JSON data like <space>Gym_Name
. So is that intentional? If not, we could try removing that.
在merge_data JSON数据中的键的开头有一个空格,如
gim_name。那么这是故意的吗?如果没有,我们可以试着移除它。
Corrected Code:
已更正代码:
json_encode([
'data' => [
[
'Gym_Name' => 'Gym1',
'Member_Name' => 'Ryle Traya',
'Parent_Name' => 'Rommel Traya',
'Contact_Phone_Number' => '09771054119'
]
]
])
Sending the data as form-data than JSON:
Corrected Code:
已更正代码:
Http::withHeaders([
'Authorization' => 'Zoho-oauthtoken ' . $accessToken['access_token']
])
-> asMultipart() # Setting form headers
->post('https://writer.zoho.com/api/v1/documents/docId/merge/sign', [
'service_name' => 'zohosign',
'filename' => 'Under Age Waiver',
'signer_data' => json_encode([
'recipient_1' => '[email protected]',
'action_type' => 'sign',
'language' => 'en'
]),
'merge_data' => json_encode([
'data' => [
[
'Gym_Name' => 'Gym1',
'Member_Name' => 'Ryle Traya',
'Parent_Name' => 'Rommel Traya',
'Contact_Phone_Number' => '09771054119'
]
]
])
]);
更多回答
我是一名优秀的程序员,十分优秀!