# Problem with external function

**URL:** <https://www.singlestore.com/forum/t/problem-with-external-function/3597>\
**Category:** Procedural SQL\
**Created:** [December 5, 2021, 2:08pm UTC](https://www.singlestore.com/forum/t/problem-with-external-function/3597 "2021-12-05T14:08:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![irinafikh](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/i/ecc23a/32.png) [@irinafikh](https://www.singlestore.com/forum/u/irinafikh)\
**Post date:** [December 5, 2021, 2:08pm UTC](https://www.singlestore.com/forum/t/problem-with-external-function/3597/1 "2021-12-05T14:08:46Z")

</div>

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](http://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](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](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/](https://rapidapi.com/community/api/open-weather-map/) to be sure that /weather exists.

Thanks!

---

<div class="post-metadata">

**Author:** ![schristian](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@schristian](https://www.singlestore.com/forum/u/schristian)\
**Post date:** [December 8, 2021, 7:41pm UTC](https://www.singlestore.com/forum/t/problem-with-external-function/3597/2 "2021-12-08T19:41:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![irinafikh](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/i/ecc23a/32.png) [@irinafikh](https://www.singlestore.com/forum/u/irinafikh)\
**Post date:** [December 12, 2021, 9:34am UTC](https://www.singlestore.com/forum/t/problem-with-external-function/3597/3 "2021-12-12T09:34:19Z")

</div>

thanks, @schristian , sorry, my mistake
