REST Resource Javascript URLs


(Chris Horikx) #1

Hi Guys,

I’m using the REST Resource JavaScript asset for a number of calls to an API. Usually, there is a single call to a single URL, but in this particular case I’m trying to call 2 different JSON endpoints entered as separate URLs on the details screen. As per the instructions, I receive two items in the _REST.Responses array, but they are both for the first URL, i.e. the same result repeated.

I’m doing this on another REST Resource Javascript asset and it work okay. The main difference between the two is only one has enabled querystring passthrough.

Is this expected behaviour?

Chris


(Bart Banda) #2

Hey Chris,
No, that sounds like a bug. What version of Matrix is that in?

Can you post a screenshot or example of the response object that Matrix gives you when you do a Run Test?

Also, what’s your caching config set up as on the REST asset?


(Chris Horikx) #3

Hey Bart,

Thanks for the quick reply, I’m working temporarily on the current VM. 5.3.1.0

Unfortunately I can’t provide the response object due to an NDA

The caching settings are set to ‘never cache’. The second URL is also pointed to an asset in Squiz Matrix, so if I put that URL first and ‘run test’ it gets a bit whacked with the querystring passthrough because of the ‘SQ_BACKEND’ variables in the backend, I believe they may also sent through which is probably also a bug.

As a workaround for now I’ll put a globals_asset_contents:id in my javascript


(Bart Banda) #4

Hmm, I can’t replicate in latest 5.3 using “https://matrix.squiz.net/” and “https://matrix-manuals.squiz.net/” as REST URLs.

Can you try those and see if you get a different result?

It’s probably better and faster to use %globals_asset_contents:id% anyways if you can use that.


(Chris Horikx) #5

Ahh, its faster with a globals keyword? Excellent thanks, I’ll just use that.

I did a bit more testing and the issue presents itself when “Append Query String” is selected.

Perhaps you also need to send query strings (I’ve been sending through a nested asset div content area)

I set one up with https://httpbin.org/get and https://matrix.squiz.net/ and the problem persisted. I turned off “Append Query String” and the problem went away.


(Bart Banda) #6

Ah yep, I can replicate it now if I use Append Query String. Definitely a bug.

I’ll get it reported and make sure it gets fixed.

To work around it you can also add %globals_get^as_url_string% onto the URL you want to pass the frontend URL queries to, or just do individual foo=%globals_get_foo% values.

Bug submitted here: https://squizmap.squiz.net/matrix/10023


(Chris Horikx) #7

Thanks Bart,

Obviously I’m unable to access that area of your website, but I’ll take your word for it

Chris