Http-functions can't have a decoded URI anymore?? starting today

Hi, I have a series problem.

I send data to my site (from an Android app) using the http-functions. It worked great until this morning.

The data I send icludes all kind of chars (Hebrew or password for examlpe), so at the very beginig of the http-function, I decoded it:

 let name = decodeURIComponent(await request.path[0]);

It was pefectly working until this morning. Now, when my url includes decoded uri, I get a HTTP ERROR 500:

Problem accessing /functions/try/%D7%A2. Reason:
Server Error

Please help me or fix this problem, my apps are down right now.

tnx

  1. Try decodeURI() (unless it contains URI reserved characters such as ? or #)

  2. Remove the “await”

  3. Check the other parts of your function.

No, doesn’t work.

I checked it all. The function works if I send data in English, but when I have an encoded uri the function doesn’t even start.

The point is that it was working until this morning!

My soultion is to send the data with queries, not path. It solves it and no need to decode. But I have al ot of work now :unamused:


BEFORE: (path[0] doesn't decoded)
https://mysite.wixsite.com/_functions/allProductsInCategory/כלים

NOW: 
https://mysite.wixsite.com/_functions/allProductsInCategory?cat=כלים

First of all, if you’re using a free Wix site so these requests are wrong.
The request should be something like:

https://mysite.wixsite.com/mysite/_functions/%D7%9B%D7%9C%D7%99%D7%9D

It will be better if you encode it before you call the request (see above).
And maybe the best way would be to use POST (then you won’t have to encode or decode anything.

POST REQ

fetch("https://mysite.wixsite.com/_functions/allProductsInCategory", 
{"method": "post",
    "body": JSON.stringify({
            "name": "כלים",
            "data": {
                "name": "מחבת",
                "subcategory": "כלי בישול"
                }
               })
}
)

And on your http-function

async function post_allProductsInCategory(req) {
	const body = await req.body.json();
	const name = body.name; 
	switch(name){
		case "כלים":
			//do something with the data
			break;
		case "רהיטים":
			//do something with the data
			break;
		//etc...
	}
}

Thanks for replying

I know the right Url’s (I have both payed and free Wix accounts for my apps), I just wrote the url for the example, from memory… I know it is not correct.

I know the use that you suggested, but since I used the request . path [] to send data (instead of making Json object) and it worked well, I wanted to keep using it. It turns out that for some reason it is no longer possible (if I want to send Hebrew data).

Never mind, I am making the changes now.

Tnx
ביי :wink: