Problem with external function

Hi All,
I try this:

CREATE LINK HTTP_link AS HTTP
CREDENTIALS ‘{“headers”:{}}’
CONFIG ‘{“headers”:{“x-rapidapi-host”: “community-open-weather-map.p.rapidapi.com”, “x-rapidapi-key”: “09e1708b03msh5f6f7593db163acp1683f8jsnbe8f998ec599”}}’;

SET GLOBAL external_functions_allowlist = ‘{ “endpoints”: [“https://community-open-weather-map.p.rapidapi.com/weather”] }’;

SET GLOBAL enable_external_functions = ‘ON’;

CREATE OR REPLACE EXTERNAL FUNCTION test.weather(q TEXT, lat INT, lon INT, callback TEXT, id INT, lang TEXT, units TEXT, mode TEXT)
RETURNS TEXT
AS REMOTE SERVICE ‘https://community-open-weather-map.p.rapidapi.com/weather
FORMAT JSON
LINK HTTP_link;

SELECT test.weather(‘Nahariya’, 0, 0, ‘test’, 2172797, ‘null’, ‘imperial’, ‘xml’);

I receive next: Error Code: 2578. {“message”:“Endpoint/weather does not exist”}

What is bad there ?

See https://rapidapi.com/community/api/open-weather-map/ to be sure that /weather exists.

Thanks!

This error is coming from the open-weather-map service because we are sending a POST and it only accepts GETs.

SingleStore external functions only support HTTP(s) POST requests because we want to batch up rows of data in the body of the request. Furthermore, we specify what that batched data looks like (i.e., a very set json format) and expect the response to send back the same json format.

You would need to write your own external function (perhaps an aws lambda?) that calls this api and transforms our batched rows into a sequence of GET requests. And also transform whatever is returned by this API into the json form that SingleStore expects.

thanks, @schristian , sorry, my mistake