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

Trigger event sends wrong payload #80

Open
clgiovannelli opened this issue Jan 29, 2025 · 1 comment
Open

Trigger event sends wrong payload #80

clgiovannelli opened this issue Jan 29, 2025 · 1 comment

Comments

@clgiovannelli
Copy link

If I try to send this payload using the trigger_event method, Novu receives a different payload. Here's the example of the payload sent and the one received:

Sent Payload:

{
  "line_items": [
    {
      "image_url": "http://domain.com/testarossa.jpg",
      "name": "Ferrari Testarossa",
      "sku_code": "TESTAROSSA",
      "quantity": "1",
      "formatted_total_amount": "€199,00"
    },
    {
      "image_url": "http://domain.com/f355.jpg",
      "name": "F355",
      "sku_code": "F355",
      "quantity": "1",
      "formatted_total_amount": "€299,00"
    },
    {
      "image_url": "http://domain.com/random.jpg",
      "name": "Ferrari Berlinetta",
      "sku_code": "MyRANDOM",
      "quantity": "1",
      "formatted_total_amount": "€99,00"
    }
  ]
}

Received Payload in Novu:

{
  "line_items": [
    {
      "image_url": [
        "http://domain.com/testarossa.jpg",
        "http://domain.com/f355.jpg",
        "http://domain.com/random.jpg"
      ],
      "name": [
        "Ferrari Testarossa",
        "F355",
        "Ferrari Berlinetta"
      ],
      "sku_code": [
        "TESTAROSSA",
        "F355",
        "MyRANDOM"
      ],
      "quantity": [
        "1",
        "1",
        "1"
      ],
      "formatted_total_amount": [
        "€199,00",
        "€299,00",
        "€99,00"
      ]
    }
  ]
}

I'm not sure why this happens—probably due to HttpParty. However, monkey-patching the trigger_event method in the Novu::Api::Event class like this makes it work correctly:

def trigger_event(body)
  post("/events/trigger", body: body.to_json, headers: { 'Content-Type': 'application/json' })
end
@clgiovannelli
Copy link
Author

Thank you @Eazybright

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

1 participant