Rest Request using POST how to send dynamic variables to a Request Body


(Tara Young) #1

I am currently using a REST asset. I have an example of my request working in Postman, and I have transfered it over to Squiz. I have JSON in the Request Body e.g. {“nameofmyservice”: {“usernameOrEmail”: “myUserName”, “request”: “5/74 Wardoo” }}. This returns data correctly from the service.

I need the request value to be populated from a search input field. I have tried to use the %globals_get_***% keyword replacement for this. {“nameofmyservice”: {“usernameOrEmail”: “myUserName”, “request”: “%globals_get_query%”}}.

And then have called the rest asset and appended the ?query=5/74+Wardoo onto the end of the url.


(Bart Banda) #2

You might find that when using this, it will URL encode any values, so 5/74+Wardoo will actually be 5%2F74%2BWardoo. So you might need to use the ^urldecode% keyword modifier. Also, it depends on how you are using the REST asset on hte frontend. Are you simply previewing it using it’s own URL?
Also, what version are you using?
A screenshot of the details screen of your REST asset would also help.