• poklos

    (@poklos)


    Hello!

    I’m trying to integrate Contact Form 7 → Webhook with an external REST API (RO App).

    The API requires a raw JSON object in the request body (Content-Type: application/json).

    However, your plugin seems to always send the body as a stringified JSON, not as a real JSON object.

    This is clearly visible in the debug email/logs:

    Request Body:
    "{
    \"lead_type_id\": 318825,
    \"contact_name\": \"John Doe\",
    \"contact_phone\": \"123456789\",
    \"description\": \"test\"
    }"

    Because the body is wrapped in quotes, the receiving API treats it as a string, fails to parse JSON, and returns validation errors (required fields reported as empty).

    Expected request body (raw JSON object, without quotes):

    {
    "lead_type_id": 318825,
    "contact_name": "John Doe",
    "contact_phone": "123456789",
    "description": "test"
    }
    "CF7 to Webhook" has a built-in feature that detects when a webhook fails and notifies you with this automated email.

    - Form: #892 - Contact form 2
    - Webhook: https://api.roapp.io/lead/
    - Error: "Webhook returned a error code."

    Request Method:
    POST

    Request Headers:
    {"Content-Type":"application\/json","Authorization":"Bearer MY API","Accept":"application\/json"}

    Request Body:
    "{\n \"_notify_leadtype_id\": 318825,\n \"contact_name\": \"Filip Pok\\u0142osiewicz\",\n \"contact_phone\": \"509465301\",\n \"contact_email\": \"[email protected]\",\n \"description\": \"terst\"\n}"

    Response Code:
    400

    Response Message:
    "Bad Request"

    Response Headers:
    {}

    Response Body:
    "{\"code\": 400, \"success\": false, \"message\": {\"validation\": {\"_notify_leadtype_id\": [\"Field cannot be empty\"]}}}"Im getting those errors. Can you help me with it?

    My questions:

    1. Is there a way in your plugin to send the request body as a raw JSON object, not a string?
    2. Is there a setting to disable JSON stringification / escaping?
    3. If not, is this a known limitation of the plugin?

    At the moment, this behavior makes it impossible to integrate with APIs that strictly validate JSON bodies.

    Thank you in advance for clarification.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Mário Valney

    (@mariovalney)

    Hi! Sorry for taking some time to get back to you.

    Thanks for the detailed report and examples.

    A quick clarification first: HTTP requests never send a “JSON object” as a native data type. They always send text (bytes). When using Content-Type: application/json, the expected payload is a JSON-formatted string, for example:

    { "field": "value" }

    This is exactly what the plugin sends.

    The body you see in the debug email: "{ \"field\": \"value\" }" is a string representation of the payload used for logging purposes, not the actual payload being transmitted over the network.

    In the request itself, the plugin sends a regular JSON.

    There is no additional JSON stringification happening at the request layer in the plugin.


    About your error

    From the response you shared, it looks like the request is reaching the RO App endpoint and being processed, but the API is rejecting it due to validation (missing/empty required fields).

    According to RO App’s “Create Inquiry” endpoint documentation:

    • client_id OR “contact_phone + contact_name” are required.
    • leadtype_id (not _notify_leadtype_id) is required.

    That said, the PHP example in their documentation also uses json_encode:

    Are you using that endpoint? https://roapp.readme.io/reference/create-lead

    Please let me know if you still need help.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.