-
Notifications
You must be signed in to change notification settings - Fork 10
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
Bulk event trigger method having problem #37
Comments
The value of subscriberId should be a string @amirali-ashraf |
Hi, I tried it by all means, and actually I am using string for all parts which is not working. I can write a quick spec test which can give you a better insight. I updated my main code as well to avoid further misunderstandings. Thanks |
Please can I see your code snippet? |
Of course! require "bundler/inline"
gemfile(true) do
ruby "3.1.2"
gem "novu"
end
client = Novu::Client.new('YOUR-API-KEY')
res = client.create_subscriber({subscriberId: 'ghgh456fthy45633efwf324r', email: '[email protected]'})
puts res
res = client.create_subscriber({subscriberId: '2fwef234rwef4teghrt7657h', email: '[email protected]'})
puts res
res = client.trigger_bulk_event({events: [
{name: 'in-app', to: {subscriberId: 'ghgh456fthy45633efwf324r'}, payload: {message: 'lorem'}},
{name: 'in-app', to: {subscriberId: '2fwef234rwef4teghrt7657h'}, payload: {message: 'lorem'}},
]})
puts res You can adjust your ruby version, btw. But if you use to_json then would work: require "bundler/inline"
gemfile(true) do
ruby "3.1.2"
gem "novu"
end
client = Novu::Client.new('your-api-key')
res = client.create_subscriber({subscriberId: 'ghgh456fthy45633efwf324r', email: '[email protected]'})
puts res
res = client.create_subscriber({subscriberId: '2fwef234rwef4teghrt7657h', email: '[email protected]'})
puts res
res = client.post('/events/trigger/bulk', body: {events: [
{name: 'in-app', to: {subscriberId: 'ghgh456fthy45633efwf324r'}, payload: {message: 'lorem'}},
{name: 'in-app', to: {subscriberId: '2fwef234rwef4teghrt7657h'}, payload: {message: 'lorem'}},
]}.to_json, headers: { 'Content-Type' => 'application/json'})
puts res |
@amirali-ashraf I guess you will have to use If you check the |
@Eazybright yeah I tried that one too, but when you use |
@amirali-ashraf I understand your point of view now. I would love to see your PR to resolve this issue with the current httpparty that's being used. |
@Eazybright Hey, thanks for you reply. My only workaround this issue is to post by converting the hash into json and set the header content to json where you post the data. Does that work for you? Also, I think this would not be the only instance that you are sending arrays. Can you tell me if there is so we can fix them in one shot or you want them to be fixed in future? |
that's the only instance for now |
@amirali-ashraf i had the same issue with the bulk subscriber creation API. You can check my PR for the fix #39 |
raised PR #45 |
|
@unicodeveloper Hi, could you please confirm when will be this part available on a new release? |
#37 add to_josn for trigger_bulk_event
When I try to use this method:
I am getting the following error:
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.
jnunemaker/httparty#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 bodyto_json
. I think that is the only work around.The harder solution is to use Faraday instead of HTTParty which is maintained better.
Thanks
The text was updated successfully, but these errors were encountered: