HarryET
10/25/2021, 9:31 AMsql
CREATE OR REPLACE FUNCTION public.events_http_send_message_event(event_id uuid, dispatch_event_type event_type, bot bot_members, message messages)
RETURNS http_client_response AS
$$
DECLARE
res http_client_response;
headers http_header[];
BEGIN
SELECT
public.events_http_headers(event_id, bot)
INTO headers;
SELECT status, content_type, content::json->>'data' AS data, content::json->>'type' as type
FROM http((
'POST',
bot.interactions_url,
headers,
-- Removed for brefiety
)::http_request
) INTO res;
RETURN res;
END;
$$ LANGUAGE plpgsql;
But it gives me this error,
invalid input syntax for type integer: \"(200,\"application/json; charset=utf-8\",,)\"
Any help would be awesome!chipilov
10/25/2021, 3:18 PMchipilov
10/25/2021, 3:20 PMchipilov
10/25/2021, 3:25 PMHarryET
10/25/2021, 3:44 PMsql
CREATE TYPE http_client_response AS
(
status integer,
content_type varchar,
data jsonb,
type integer
);
chipilov
10/25/2021, 4:02 PMchipilov
10/25/2021, 4:02 PMchipilov
10/25/2021, 4:02 PMHarryET
10/25/2021, 4:02 PMHarryET
10/25/2021, 4:03 PMsql
CREATE OR REPLACE FUNCTION public.events_dispatch_message(event_id uuid, dispatch_event_type event_type, message_id uuid, client bot_members)
RETURNS VOID AS
$$
DECLARE
message messages;
res http_client_response;
BEGIN
SELECT
*
INTO message
FROM messages
WHERE id = message_id;
SELECT
public.events_http_send_message_event(event_id, dispatch_event_type, client, message)
INTO res;
END;
$$ LANGUAGE plpgsql;
HarryET
10/25/2021, 4:03 PMHarryET
10/25/2021, 4:03 PMchipilov
10/25/2021, 4:06 PMchipilov
10/25/2021, 4:06 PMSELECT
public.events_http_send_message_event(event_id, dispatch_event_type, client, message)
INTO res;
HarryET
10/25/2021, 4:07 PMchipilov
10/25/2021, 4:07 PMchipilov
10/25/2021, 4:08 PMchipilov
10/25/2021, 4:08 PMHarryET
10/25/2021, 4:09 PMsql
EXECUTE public.events_http_send_message_event(event_id, dispatch_event_type, client, message);
HarryET
10/25/2021, 4:09 PMsyntax error at or near \"200\"
chipilov
10/25/2021, 4:36 PMchipilov
10/25/2021, 4:50 PMchipilov
10/25/2021, 4:50 PMHarryET
10/25/2021, 4:50 PMchipilov
10/25/2021, 4:50 PMchipilov
10/25/2021, 4:50 PMchipilov
10/25/2021, 4:51 PMchipilov
10/25/2021, 4:51 PMHarryET
10/25/2021, 4:58 PMchipilov
10/25/2021, 4:58 PMHarryET
10/25/2021, 4:58 PMHarryET
10/25/2021, 4:58 PMchipilov
10/25/2021, 5:00 PMHarryET
10/25/2021, 5:00 PMchipilov
10/25/2021, 5:03 PMHarryET
10/25/2021, 5:04 PMHarryET
10/25/2021, 5:04 PM