Rest Get Query parameter particular filter criteria not working

I am doing an API call by passing dynamic timestamp in Query Parameters section , here is the value I am passing
“INSTALLED_SW_LAST_CHANGE_TIMESTAMP%20ge%20”+Date.now().toLocaleDateString()+“T15:00:00-05:00)”.
I am getting status code error 400

But if I am passing same value in edit pipeline section as below pic , pipeline works fine.


Can you please help me to resolve this issue. Thank you for your help.

Hi,

The provided information is not enough. could you execute the pipeline and share the detailed error log of the rest Get?
Also try and replace %20 with + as below and give it a try.
“INSTALLED_SW_LAST_CHANGE_TIMESTAMP+ge+”+Date.now().toLocaleDateString()+“T15:00:00-05:00)”

It didn’t work when filter is given in REST GET
But when I give in edit pipeline it works.
Here is the error log

REST API service endpoint returned error result: status code = 400

Resolution:

Please check the values of Snap properties.

Reason:

REST API service endpoint returned error result: status code = 400, reason phrase = Bad Request, refer to the error_entity field in the error view document for more details

Hide Details…

REST Get[592dae2559ee13133f007722_63f2942e-f7da-46bc-b36d-a5798debc42e – 059bb661-6992-47e5-9874-3d255a2be639]
`com.snaplogic.snap.api.SnapDataException: REST API service endpoint returned error result: status code = 400
at com.snaplogic.snap.api.rest.RestResponseProcessor.process(RestResponseProcessor.java:379)
at com.snaplogic.snap.api.rest.RestRequestExecutor.execute(RestRequestExecutor.java:426)
at com.snaplogic.snap.api.rest.RestRequestExecutor.executeOnce(RestRequestExecutor.java:323)
at com.snaplogic.snap.api.rest.RestRequestExecutor.execute(RestRequestExecutor.java:190)
at com.snaplogic.snap.api.rest.RestRequestExecutor.execute(RestRequestExecutor.java:173)
at com.snaplogic.snaps.rest.Get.process(Get.java:124)
at com.snaplogic.snap.api.ExecutionUtil.process(ExecutionUtil.java:106)
at com.snaplogic.snap.api.ExecutionUtil.execute(ExecutionUtil.java:70)
at com.snaplogic.snap.api.SimpleSnap.execute(SimpleSnap.java:70)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.executeSnap(SnapRunnableImpl.java:812)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.execute(SnapRunnableImpl.java:586)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.doRun(SnapRunnableImpl.java:877)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:436)
at com.snaplogic.cc.snap.common.SnapRunnableImpl.call(SnapRunnableImpl.java:120)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Reason: REST API service endpoint returned error result: status code = 400, reason phrase = Bad Request,
refer to the error_entity field in the error view document for more details
Resolution: Please check the values of Snap properties.

Error Fingerprint[0] = efp:com.snaplogic.snap.api.rest.89xhsFt7`

Hi @deepthi.chidi

My bad on suggesting to put + instead of %20, it generally works if you put the query parameters directly in the URI field.

I gave it a try, see the below screenshot.

where ever in your query you’ve space leave them as it is, it’ll be translated to %20 and same with other special characters.
“INSTALLED_SW_LAST_CHANGE_TIMESTAMP get ”+Date.now().toLocaleDateString()+“T15:00:00-05:00)”

For me, it worked fine when I removed the %20 and + from the filter string.

Hope this helps.

Cheers

I am facing still same issue when I pass filter criteria in REST GET snap .
But when I try in edit pipeline and passing same filter criteria it works (all formats are working, %20,space and +)
I am not sure at this point why same filter criteria is not working when given REST GET snap :frowning:

This is weird indeed, can you try to put everything in the Service URL and try it? Don’t pass them via query parameters[Although it should work].

If TIMESTAMP value is hard coded in service URL it works, but if same value given in query parameter it doesn’t work .

eg - https://test.com/latest/INSTALLED_SOFTWARE?$orderby=DEVICE_NAME&$filter=(INSTALLED_SW_LAST_CHANGE_TIMESTAMP%20ge%202023-05-17T13:00:00-05:00)&$top=50

Hi @Soni37,

I can see your filter added as a query parameter is missing an opening parenthesis, maybe that’s the problem?

Other thing I would like to add is that passing the same expression as a parameter won’t be evaluated, and it is going to be considered as a string.
Meaning, the part Date.now().toLocaleDateString() will not be evaluated tto the current DateTime.

Hope this helps,
Regards,
Bojan

1 Like

@bojanvelevski
The same parameter when given in edit pipeline works, and also when I try to evaluate in query parameter I get valid format.