novu-ruby
novu-ruby copied to clipboard
Bulk event trigger method having problem
When I try to use this method:
client = Novu::Client.new(<API-KEY>)
client.trigger_bulk_event(
events: [
{name: 'name', to: {subscriberId: 'asdfasdf'}, payload: {message: 'lorem'}},
{name: 'name', to: {subscriberId: 'sdfgsdfg'}, payload: {message: 'lorem'}},
]
)
I am getting the following error:
{"data"=>[{"status"=>"error", "error"=>["identifier must be a string"], "acknowledged"=>true}]}
I noticed that there is an issue with the HTTParty when you want to submit an array as a body. It does not parse it properly.
https://github.com/jnunemaker/httparty/issues/719
I can help to address the issue if we can agree on a solution.
My suggestion is to make add headers: { 'Content-Type' => 'application/json' }
to all or post requests and also, convert post body to_json
. I think that is the only work around.
The harder solution is to use Faraday instead of HTTParty which is maintained better.
Thanks