[5.0.0-MarchDB] [curl()] "Unrecognizable prepared statement - cause: Invalid prepared stmt \"\u003cbinary (65 b)\u003e\" in curl()

I am using 5.0.0-2194 Enterprise Edition (build-2194).
when I run the following N1QL

SELECT CURL("GET","http://192.168.199.128:4984/sg/_changes", 
            {"header":"Cookie: SyncGatewaySession=b71792a2f40c36e26bf7a0bfd1e745f520521711","data":"feed=normal&feed=normal&include_docs=false&active_only=false"}).last_seq

it works fine.

but when I want to Parametric address and cookies like,

curl -v http://127.0.0.1:8093/query/service --data-urlencode 'statement=PREPARE queryLastSeq FROM SELECT CURL("GET","$sg_address", {"header":"Cookie:SyncGatewaySession=$Cookie","data":"feed=normal&feed=normal&include_docs=false&active_only=false"}).last_seq;'

and when I run by

curl -v http://j127.0.0.1:8093/query/service -d 'prepared="queryLastSeq"&$sg_address="http://192.168.199.128:4984/sg/_changes"&$Cookie="b71792a2f40c36e26bf7a0bfd1e745f520521711"'

I got the following error:

    "errors": [
        {
            "code": 5010,
            "msg": "Error evaluating projection. - cause: curl: Couldn't resolve host name"
        }
    ],
    "status": "errors",

When I only Parametric cookies by

curl -v http://127.0.0.1:8093/query/service --data-urlencode 'statement=PREPARE queryLastSeq2 FROM SELECT CURL("GET","http://192.168.199.128:4984/sg/_changes", {"header":"Cookie:SyncGatewaySession=$Cookie","data":"feed=normal&feed=normal&include_docs=false&active_only=false"}).last_seq;'

and run

curl -v http:/127.0.0.1:8093/query/service -d 'prepared="queryLastSeq2"&$Cookie="b71792a2f40c36e26bf7a0bfd1e745f520521711"'

I got the following error

    "errors": [
        {
            "code": 4050,
            "msg": "Unrecognizable prepared statement - cause: Invalid prepared stmt \"\u003cbinary (65 b)\u003e\""
        }
    ],
    "status": "fatal",

notice:
If I don’t Parametric address and cookies by

curl -v http://127.0.0.1:8093/query/service --data-urlencode 'statement=PREPARE queryLastSeq3 FROM SELECT CURL("GET","http://192.168.199.128:4984/sg/_changes", {"header":"Cookie:SyncGatewaySession=b71792a2f40c36e26bf7a0bfd1e745f520521711","data":"feed=normal&feed=normal&include_docs=false&active_only=false"}).last_seq;'

it works fine.

may be I need Parametric any parameter in header or data.

Hi @atom_yang,

What are you trying to do by passing prepared statements to CURL?

cc @isha @marcog @keshav_m

I want to dump some data by address and some request parameter in prepared statements.it will be very useful function for exchange data with 3td service.
for this example, I want to get last_seq from SG _changes APIs without get docs in the client.

Hi, Same CURL() query don’t work in CBDP 5.0.0-2564 Enterprise Edition (build-2564) with the following error:

[
  {
    "code": 3000,
    "msg": "Wrong number of arguments to function CURL. - at )",
    "query_from_user": "SELECT CURL(\"GET\",\"http://192.168.199.128:4984/sg/_changes\", \n            {\"header\":\"Cookie: SyncGatewaySession=b71792a2f40c36e26bf7a0bfd1e745f520521711\",\"data\":\"feed=normal&feed=normal&include_docs=false&active_only=false\"}).last_seq"
  }
]

Hi @atom_yang, try removing the GET parameter.

Copying @isha.

Hi @atom_yang,

We have changed the CURL function definition with the new DP. Hence you might be hitting this issue. I have updated the CURL article, which will be updated in a day or 2.

The following is the new signature :

CURL (url, {options})
Arguments - url
Optional Arguments - list of options

If you explicitly want to provide a request method type you can use the request option to set POST method type, and the get option to set GET. These are set as part of the options (argument 2) for the CURL function.

Thanks
Isha

can you give me the document link for CURL function?