Using SSJS to set GET parameters for a REST resource asset


(Pete) #1

Matrix Version: 6.26.0

Hello,

I am trying to create a component template that queries a database. Editors will be able to change what information is returned from the database by changing the settings on the CCT.

I have all of the pieces together but for the life of me I cannot get the query parameters through to the REST asset.

In my paint layout I have the following:

<script runat="server">
//code to process user input into queryString variable
//for example it would resolve to 'subjects\:subjects\:ANY\:EQ\:110503'


    print(`%globals_asset_contents_raw:2076241^with_get:test=${queryString}%`)
    
</script>

Then in the URL of my REST asset I have:

https://myurl.com?defaultparameters&%globals_get_test^as_url_string%

The first line of my JS processing I am printing out the Query URL and the keyword appears to have resolved as I intended. When when I print out the response body it’s empty

What really stumps me is that if I hard code the query parameter in the paint layout everything works as intended.

I’ve tried just about everything I can think of. Any advice would be much appreciated!

Thanks in advance!


#2

In your REST resource, what are your settings for these 2 options?