#Interactions Endpoint: interactions_endpoint_url: The specified interactions endpoint url could not

1 messages · Page 1 of 1 (latest)

loud remnant
#

I am getting:
interactions_endpoint_url: The specified interactions endpoint url could not be verified.

When trying to verify my bots Itneractions Endpoint URL. I have this code to do that.

The first requests has IsValidHttpInteraction and does the AcknowledgePing, second request I receive fails

        private string _publicKey = Environment.GetEnvironmentVariable("DISCORD_PUBLIC_KEY");

        [Function("InteractionsEndpoint")]
        public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestData req)
        {
            HttpResponseData Respond(HttpStatusCode statusCode, string responseBody)
            {
                var response = req.CreateResponse(statusCode);
                response.Headers.Add("content-type", "application/json");
                response.WriteString(responseBody);
                return response;
            }

            _logger.LogInformation("Received request");

            string? signature = req.Headers.GetValues("X-Signature-Ed25519").FirstOrDefault();
            string? timestamp = req.Headers.GetValues("X-Signature-timestamp").FirstOrDefault();
            string? requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            _logger.LogInformation(requestBody);

            if (!discord.IsValidHttpInteraction(_publicKey, signature, timestamp, requestBody))
            {
                return Respond(HttpStatusCode.BadRequest, "Invalid Interaction Signature!");
            }

            RestInteraction interaction = await discord.ParseHttpInteractionAsync(_publicKey, signature, timestamp, requestBody);

            if (interaction is RestPingInteraction pingInteraction)
            {
                return Respond(HttpStatusCode.OK, pingInteraction.AcknowledgePing());
            }
loud remnant
#

Okay so I had to change the code since Discord changed what response they want to receive on the bad signature. They want this now

return await Respond(HttpStatusCode.Unauthorized, "Invalid Interaction Signature!");