issue in trigger and subscriber create with .net sdk
by:- @sarucchi.
Message Ref:- https://discord.com/channels/895029566685462578/1148525267879469066/1150588410298376213
52 Replies
HI
Is anyone having this issue or I am doing something wrong?
Can you please share this error
WaitigForActivation
screenshot?@dr.really tagging you here just in case. Also please can you provide the version of the SDK you are using? @bsantosh909
👀
Wrong person mentioned 😅
@sarucchi.
Sorry 😅
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
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 ? 🙂
@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
try
@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
Are you using the hosted version of Novu?
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
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 valueYet 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
When you go to
~/v1/health-check
what do you see?{"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"}}}
@saruchi_13291_71869, you just advanced to level 4!
Looks like your API is erroring, your inMemory is down
@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?
yessir, one moment
I had to set thethese are environment variablesIN_MEMORY_CLUSTER_MODE_ENABLED
to false, but then also setREDIS_CACHE_SERVICE_HOST
andREDIS_CACHE_SERVICE_PORT
to the same values asREDIS_HOST and REDIS_PORT
thanks @dr.really . @saruchi_13291_71869 please try those
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
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
@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
Where did you get your API key from?
self hosted Novu's - Settings
I think you are using application identifier instead of api key
the value should be the api key
I am sending VALUE as API key
and Application Identifier in KEY (tried sending nothing at all in KEY) but 401
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
I still see 401 in postman with above 😦
let's enter dms. one of the keys must still be wrong
dms? how?
i sent you a private message
@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"}
but Post throws these errors: {"statusCode":400,"message":["subscriberId should not be null or undefined","subscriberId must be a string"],"error":"Bad Request"}
are you providing a subscriber id?
@dr.really, you just advanced to level 10!
yes and email
tried in string and alphanumeric
Show me your post example
added Authorization in Headers ..
Authorization Type: NoAuth
works well with GET
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:
Its working !!!!!
Added a subscriber
I tried with sending Raw text ..selected json now and it works!!!
Thank you!
anytime!
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
have tried with both using await and not using await
So the status WaitingForActivation, when you run it with
await
what does it give you?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 🙂
I'm glad this finally worked!!! Yaaaaaaay!!!