N
Novu•14mo ago
Pawan Jain

issue in trigger and subscriber create with .net sdk

52 Replies
Saruchi
Saruchi•14mo ago
HI Is anyone having this issue or I am doing something wrong?
Pawan Jain
Pawan Jain•14mo ago
Can you please share this error WaitigForActivation screenshot?
Prosper
Prosper•14mo ago
@dr.really tagging you here just in case. Also please can you provide the version of the SDK you are using? @bsantosh909
Santosh Bhandari
Santosh Bhandari•14mo ago
👀
Pawan Jain
Pawan Jain•14mo ago
Wrong person mentioned 😅 @sarucchi.
Prosper
Prosper•14mo ago
Sorry 😅
Saruchi
Saruchi•14mo ago
this is not an error But i am not able to send the email or create a subscriber The .net quick start document doesnt seem to work so checking here
No description
Saruchi
Saruchi•14mo ago
No description
Saruchi
Saruchi•14mo ago
var novuConfiguration = new NovuClientConfiguration { Url = "", //self hosted ApiKey = "", }; var novu = new NovuClient(novuConfiguration); // Create subscriber var newSubscriberDto = new SubscriberCreateData { SubscriberId = "9", FirstName = "", LastName = "", Email = "", Data = new List<AdditionalData> { new AdditionalData { Key = "External ID", Value = "1122334455" }, new AdditionalData { Key = "Job Title", Value = "Software Engineer" } } }; var subscriber = novu.Subscriber.Create(newSubscriberDto); var onboardingMessage = new OnboardEventPayload { Username = "SA", WelcomeMessage = "Welcome to novu-dotnet" }; var payload = new Novu.DTO.Events.EventCreateData() { EventName = "onboarding", //have a trigger named "onboarding" in self hosted Novu To = { SubscriberId = "9" }, Payload = onboardingMessage }; var trigger = novu.Event.Trigger(payload); if (trigger.IsCompleted) // changed from - trigger.TriggerResponsePayloadDto.Acknowledged (in documentation) { Console.WriteLine("Trigger has been created."); } @unicodeveloper I am using 0.3.2 @unicodeveloper @Pawan Jain : please let me know if you need any other information @Pawan Jain @unicodeveloper anything on this ? 🙂
Prosper
Prosper•14mo ago
@sarucchi. please i need you to do me a favour, can you try creating a subscriber via the API, maybe through postman or an alternative, i need to be sure if it's an sdk issue or not. it;s a pretty new type of issue
dr.really
dr.really•14mo ago
try
var subscriber = await novu.Subscriber.Create(newSub);
var subscriber = await novu.Subscriber.Create(newSub);
Saruchi
Saruchi•14mo ago
@dr.really Thanks for your response I have tried with both using await and dropping await but no subscriber is created Can you please confirm what URL should i provide in NovuClientConfiguration { Url = "", //self hosted } any working example would be much appreciated
dr.really
dr.really•14mo ago
Are you using the hosted version of Novu?
Saruchi
Saruchi•14mo ago
self hosted version of Novu have tried with API_Root_Url as well something like http://35.154.137.80:3000 but doesnt seem to work **here 35.154.137.80 is example EC2 VM IP which will be different for different VM
dr.really
dr.really•14mo ago
assuming the http:35.154.137.80:3000 is the address the api is running at, you would put http://35.154.137.80:3000/v1 as the Url value
Saruchi
Saruchi•14mo ago
Yet it did not create any subscriber in my self hosted Novu with this code:- public void CreateNotification(OnboardEventPayload requestPayload) { var novuConfiguration = new NovuClientConfiguration { Url = Secrets.Notification_Url, ApiKey = Secrets.Notification_Api_Key }; var novu = new NovuClient(novuConfiguration); // Create subscriber var newSubscriberDto = new SubscriberCreateData { SubscriberId = "9", //replace with system_internal_user_id FirstName = "xx", LastName = "x", Email = "xxx" }; var subscriber = novu.Subscriber.Create(newSubscriberDto); @dr.really I have tried following:- 1. Subscriber.Create with with await - result no subscriber created 2. URL - domain/api/v1 (like https://imaginary.something.something/api/v1) 3. providing URL - http://35.154.137.80:3000/v1
dr.really
dr.really•14mo ago
When you go to ~/v1/health-check what do you see?
Saruchi
Saruchi•14mo ago
{"status":"error","info":{"db":{"status":"up"},"apiVersion":{"version":"0.17.1","status":"up"},"triggerQueue":{"status":"up"}},"error":{"inMemory":{"status":"down"}},"details":{"db":{"status":"up"},"apiVersion":{"version":"0.17.1","status":"up"},"triggerQueue":{"status":"up"},"inMemory":{"status":"down"}}}
Novu_Bot
Novu_Bot•14mo ago
@saruchi_13291_71869, you just advanced to level 4!
dr.really
dr.really•14mo ago
Looks like your API is erroring, your inMemory is down
Prosper
Prosper•14mo ago
@dr.really the config you did that day for inMemory, can you repeat here just so we are sure he configured it the right way?
dr.really
dr.really•14mo ago
yessir, one moment
I had to set the IN_MEMORY_CLUSTER_MODE_ENABLED to false, but then also set REDIS_CACHE_SERVICE_HOST and REDIS_CACHE_SERVICE_PORT to the same values as REDIS_HOST and REDIS_PORT
these are environment variables
Prosper
Prosper•14mo ago
thanks @dr.really . @saruchi_13291_71869 please try those
Saruchi
Saruchi•14mo ago
ok,thanks let me try @dr.really @unicodeveloper One more question.. Can i hit the Novu end points through Swagger? I get 401 -unauthorized Where can i set the authorization in ~/api
Prosper
Prosper•14mo ago
We recommend you just that as a guide on what request body to send. You have to use postman or an alternative to try it. We are launching something tomorrow or next to allow you try it directly from the docs
Saruchi
Saruchi•14mo ago
@unicodeveloper I am using Postman with URL 1. ~/api/v1/subscribers 2. with same body params as in ~/api { "subscriberId": "123", "email": "[email protected]", "firstName": "string", "lastName": "string", "phone": "string", "avatar": "string", "locale": "string", "data": {} } 3. Authorization as APIKey key: APIKey -Use this API key to interact with the Novu API value: Application Identifier A public key identifier that can be exposed to the client applications but getting 401
Prosper
Prosper•14mo ago
Where did you get your API key from?
Saruchi
Saruchi•14mo ago
self hosted Novu's - Settings
Prosper
Prosper•14mo ago
I think you are using application identifier instead of api key
Prosper
Prosper•14mo ago
the value should be the api key
No description
Saruchi
Saruchi•14mo ago
No description
Saruchi
Saruchi•14mo ago
I am sending VALUE as API key and Application Identifier in KEY (tried sending nothing at all in KEY) but 401
Prosper
Prosper•14mo ago
Application identifier should never be used here, you only use that on the frontend Key: ApiKey Value: xxxxxxxxxxxxxxxxxxxxxxxxx where xxxxxx is your actual api key or forget about the authorization and just put this in your headers. this works better: header: Authorization value: ApiKey xxxxxxxxxxxxxxxxxx
Saruchi
Saruchi•14mo ago
I still see 401 in postman with above 😦
Prosper
Prosper•14mo ago
let's enter dms. one of the keys must still be wrong
Saruchi
Saruchi•14mo ago
dms? how?
Prosper
Prosper•14mo ago
i sent you a private message
Saruchi
Saruchi•14mo ago
@dr.really {"data":{"status":"ok","info":{"db":{"status":"up"},"inMemory":{"status":"up"},"apiVersion":{"version":"0.17.1","status":"up"},"triggerQueue":{"status":"up"}},"error":{},"details":{"db":{"status":"up"},"inMemory":{"status":"up"},"apiVersion":{"version":"0.17.1","status":"up"},"triggerQueue":{"status":"up"}}}} made the changes and in memory status is up Get Subscribers is working ,thanks to @unicodeveloper
but Post throws these errors: {"statusCode":400,"message":["subscriberId should not be null or undefined","subscriberId must be a string"],"error":"Bad Request"}
dr.really
dr.really•14mo ago
are you providing a subscriber id?
Novu_Bot
Novu_Bot•14mo ago
@dr.really, you just advanced to level 10!
Saruchi
Saruchi•14mo ago
yes and email tried in string and alphanumeric
dr.really
dr.really•14mo ago
Show me your post example
Saruchi
Saruchi•14mo ago
No description
Saruchi
Saruchi•14mo ago
added Authorization in Headers .. Authorization Type: NoAuth works well with GET
dr.really
dr.really•14mo ago
you're using a form body, isn't this just a normal post body? switch to raw and select json and then put something like:
{
"subscriberId": "abc123",
"email": "[email protected]"
}
{
"subscriberId": "abc123",
"email": "[email protected]"
}
Saruchi
Saruchi•14mo ago
Its working !!!!! Added a subscriber I tried with sending Raw text ..selected json now and it works!!! Thank you!
dr.really
dr.really•14mo ago
anytime!
Saruchi
Saruchi•14mo ago
Now that Postman request is working 🙂 Something is wrong with my .net code as well because I am not able to create a subscriber through code var subscriber = novuClient.Subscriber.Create(SubscriberCreateData) Do you follow the .Net quickstart tutorial? because I see some class names have changed so asking
No description
Saruchi
Saruchi•14mo ago
have tried with both using await and not using await
dr.really
dr.really•14mo ago
So the status WaitingForActivation, when you run it with await what does it give you?
Saruchi
Saruchi•14mo ago
when i run it with await,i dont get to know what happens after this line var subscriber = await novu.Subscriber.Create(newSubscriberDto); it comes out of the debug and I get my Swagger End point screen from which I am calling this code @dr.really @unicodeveloper i am able o create a subscriber and send email to the subscriber from .net as well now with await I changed my ApiKey and removed the prefix ApiKey which I was using for postman Thanks 🙂
Prosper
Prosper•14mo ago
I'm glad this finally worked!!! Yaaaaaaay!!!
Want results from more Discord servers?
Add your server