Closed jlabs closed 1 month ago
Updated to 3.0.0-beta.10 and the error has now changed. I now get "API error: “Call to a member function getBody() on string” /Users/j/Dev/cut-and-craft/vendor/verbb/formie/src/integrations/webhooks/Webhook.php:68"
All this test function does is:
public function actionTest() : Response
{
// Create a response to return
$response = Craft::$app->getResponse();
// Set the response body to JSON
$response->format = Response::FORMAT_JSON;
// Set status
$response->setStatusCode(200, 'OK');
// Set data
$response->data = [
'message' => 'Message sent',
'status' => 'sent'
];
return $response;
}
Found the issue.
In Webhook.php
line 68 is $rawResponse = (string)$response->getBody();
. The issue is my returned response (for some reason) is causing the ->getBody()
to be missing.
If I reve that line and just use $json = Json::decodeIfJson($response);
instead, then it returns a valid response back to the "Send Test Payload" button
Is getBody()
required? In the function request
found in Integration.php
, it has return ($decodeJson) ? Json::decode($response->getBody()->getContents()) : $response->getBody()->getContents();
Would that not already be doing the getBody()
and returning the body/contents?
Fixed for the next release. To get this early, run composer require verbb/formie:"dev-craft-5 as 3.0.0-beta.10"
.
Fixed in 3.0.0-beta.11
Describe the bug
I've made a controller to post form submissions to a 3rd party CRM - that all works testing through Postman.
As I understand it, I need to create a webhook - which I have done. I've set the URL to the route specified in the
routes.php
file for Craft. I've then gone to the form that is to use the webhook and added it into the Integrations tab and enabled it.When I click on "Send Test Payload" I get
AxiosError: Request failed with status code 500
. I've also tried making a test endpoint that returns a 200 status, but that doesn't work either (same error).Looking at the network table in dev tools, I can see the request being made but there's the 500 error with the message "Connect to the integration provider first".
Have I missed a step? I'm not sure how I would connect to the integration provider if the provider is the same site the form is on.
Steps to reproduce
Form settings
Craft CMS version
5.0.5
Plugin version
3.0.0-beta.9
Multi-site?
No
Additional context
No response