How can I set the authorization header for webhooks in the new UI?

I watched this video (found it here on Moralis):

The lecturer sets the authorization header around 13:24. However, this option doesn’t exist anymore. I can’t write any code, I can only specify the webhook URL.

Is it possible to set the authorization header in the new UI and if so, how?

Can you paste the code example?

There will be moralis.io/streams released soon

1 Like

Sure, so he navigates to the Admin UI, clicks Cloud functions and writes the following (there might be typos as I copied it from a screenshot, this is just to demonstrate his code):

Moralis.Cloud.beforeSave("NewDonations", async (request) => (
let data = {
     app id: "10c413ad-e935-49lb-blla-3f9dle7al2ec",
     contents: ("en": "Hello"},
     included segments: ["Subscribed Users"],
     name: "SMS",
     sms_from: "+447476557244"
}

Moralis.Cloud.httpRequest((
     method: "POST',
     url: "https://onesignal.com/api/v1/notifications",
     body: data,
     headers: {
          "Content-Type": "application/json",
          "Authorization": "Basic NTRhZGEyYTEtY2NhOSOONDhjLT1mN2ItyTI0MzBmMzOwMmU3'
     }
     })
})

So he isn’t using the new Webhook functionality, right? It looks like he’s just defining cloud code.

It looks like a simple http request, you can use anything you want there in that http request.

That’s awesome, thank you.