cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

API query invalid in SnapLogic, but valid in Postman

Garrett
New Contributor II

Split out from: 401 Error using Https in API REST GET call

Did you ever solve your issue?

I am experiencing something similar. To answer the question the User-Agent can be anything. Something like SnapLogic/version# replacing the number.

My issue is that when I run it in Postman I get results.
When I run it in SnapLogic the Server is saying that the query is invalid.

17 REPLIES 17

Garrett
New Contributor II

It is not SQL. It is Oracleโ€™s proprietary language ROQL.

I am not sure how to send you the configuration.

Post a screenshot of the REST Get settings.

Let me clarify what would help us help you. You said you tried making a query with Postman which worked, but you tried making the same query with REST Get which didnโ€™t work. Please post a screenshot of both showing the full configuration.

Garrett
New Contributor II

I have tried all kinds of permutations and combinations of these settings. Regardless of the settings or if I use the encodeURIComponent(โ€˜select * from mytable where id < 1000โ€™) in the Parameter or the = is checked or unchecked. I get different errors for all of those scenarios. The only thing that works is what I posted first with he encodeURIComponent.

image

Ok, I know whatโ€™s going on. Hereโ€™s the pipeline I describe below:
REST param encode_2021_01_29.slp (4.6 KB)

This uses a simple REST API provided by Postman called โ€œechoโ€: Echo API | Postman Learning Center

The pipeline has two instances of the REST Get snap configured differently:
image

โ€œREST Get encodeโ€ is configured with an expression in the Service URL which uses encodeURIComponent to encode the query parameter value:
image

โ€œREST Get simpleโ€ is configured without using any expressions; it uses the Query Parameters table to pass the query parameter and leaves it out of the Service URL:
image

Both of these work as expected, but they encode the URL a little differently.

Hereโ€™s the output of both snaps. The echo APIโ€™s response shows both the โ€œurlโ€ it received and how it was decoded under โ€œargsโ€:
Screen Shot 2021-01-29 at 3.36.45 PM
Screen Shot 2021-01-29 at 3.35.34 PM

Notice that the URL is different: the โ€œREST Get encodeโ€ encodes the spaces in the query value as โ€œ%20โ€, while the โ€œREST Get simpleโ€ encodes them as โ€œ+โ€. But both of these are valid ways to encode a space in a URL. And youโ€™ll notice that the echo API decodes them the same way; both produce the same resulting โ€œargsโ€ value, the same decoded string where both %20 and + are decoded as a space.

The API you are calling is not understanding them the same way. Itโ€™s correctly decoding %20 as a space, but itโ€™s not correctly decoding + as a space.

Do you have control over the implementation of the API youโ€™re calling to fix it on the server side so it accepts either valid encoding?