UrlFetch json doesn't work with SSL URLs

I don’t know if it’s because of the Eval or something else, but even the example from the docs fails and the error is always the same:

$(eval const api = $(urlfetch json https://en.wikipedia.org/w/api.php?format=json&action=opensearch&search=$(querystring)); api.error || !api[1][0] ? 'Please add a query to the search' : ${api[1][0]} - ${api[3][0]})

Right-hand side of 'instanceof' is not an object

On the other hand, the HTTP command from thread #16377 works (sorry I can’t link yet).

Hiya, this is probably due to the markup of the docs page. A copy paste example:

Wikipedia Article: $(eval const api = $(urlfetch json https://en.wikipedia.org/w/api.php?format=json&action=opensearch&search=$(querystring)); api.error || !api[1][0] ? 'Please add a query to the search' : `${api[1][0]} - ${api[3][0]}`)

Only change is the backquotes at the end to output the response.

Thanks, but why does this work
$(eval const api = $(urlfetch json http :// api . satont . ru/faceit?nick=test); ${JSON.stringify(api)})
And not this
$(eval const api = $(urlfetch json https :// www . instagram . com/google/?__a=1); ${JSON.stringify(api)})

(spaces are there because I can’t post links)

EDIT: this seems to trigger a fetch but the response should be JSON, yet I get HTML, a problem with the user agent?
$(eval const api = $(urlfetch json https :// www . instagram.com/google/?__a=1); JSON.stringify(api).substr(0, 100))

EDIT: I’m leaning towards a problem with URL parameters starting with __

I dont think instagram is returning JSON on that url, or well, it works when I open the link in a browser. However when I try to fetch it from a script, it returns me a login page.

It will redirect to: https://www.instagram.com/accounts/login/?next=/google/%3F__a%3D1

Yes, I see the problem now, they have some kind of protection :-/
Sorry for disturbing you

Yeah unfortunate, and no problem at all!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.