N
Novu6mo ago
N01R

401 error on self deployed

Hey i got an issue here, I self deployed my novu over and tried putting my new API key but its giving the response 401 when i tried to create a new subscriber
3 Replies
N01R
N01R6mo ago
should i also add the env id and the application identifier? here is the code that i wrote to create the sub
export const createSub = async (req, res) => { const novu = new Novu(NOVU_API_KEY); console.log('createSub ', NOVU_API_KEY); try { // Call Novu SDK to create the subscriber with id = 78449 const subscriber = await novu.subscribers.identify('234', { email: 'sreevats@tresfdww.com', firstName: 'John', lastName: 'Doe', phone: '+13603963366', avatar: 'https://example.com/images/avatar.jpg', locale: 'en', data: { customKey1: 'customVal1', customKey2: 'customVal2' }, "channels": [ { "credentials": { "deviceTokens": [ "token1", "token2" ] }, "_integrationId": "NOVU_GENERATED_INTEGRATION_ID", "providerId": "fcm" }, { "credentials": { "webhookUrl": "URL" }, "_integrationId": "NOVU_GENERATED_INTEGRATION_ID", "providerId": "discord" } ], "deleted": false, "createdAt": "2022-10-13T17:40:53.231Z", "updatedAt": "2022-10-13T17:41:53.238Z", "__v": 0, "isOnline": false, "lastOnlineAt": "2022-10-13T17:41:53.238Z", "avatar": "AVATAR_URL", "id": "NOVU_GENERATED_SUBSCRIBER_ID" } ); // Return the subscriber ID in JSON response res.status(200).json(circularJson.stringify(subscriber)); } catch (error) { res.status(500).json(circularJson.stringify({ message: error.message })); } }
and when i tried calling this it gave me an unauthorized The error message was : "{"message":"Request failed with status code 401"}"
AINAR
AINAR6mo ago
I think that u need to specify the backendUrl when u instantiate Novu
No description
N01R
N01R6mo ago
ahh it works thanks