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

Issue with Date Parameter in API call filter

camaliontij
Deputy Chef I
Deputy Chef I

Hello,

 

I have an API call with a date filter and I want to get the information from the last 30 days. So I created a parameter like this:

today-30.days

and called it "Last30days". Then I added the parameter to my API call to be like this:

my_API_call_?$filter=PostingDate gt {Last30Days}

but it's not working and I'm getting the following error:

"A binary operator with incompatible types was detected. Found operand types 'Edm.Date' and 'Edm.String' for operator kind 'GreaterThan'."

Any idea on what would be the right way to do this?

Thanks!

23 REPLIES 23

gary1
Executive Chef III
Executive Chef III

@Prudvi I was looking at your screenshot again and this is incorrect.

Setting a param name to "$filter=PostingDate%20gt%20" and a value to "today" will create a result with two "=" characters:

$filter=PostingDate%20gt%20=2025-02-14

Workato places "=" between the param name and the value.

The correct way is to set the param as "$filter" and the value as "PostingDate%20gt%20" + a date

Hi @gary1 and @Prudvi,

Thanks for explaining the data pill, that makes a lot of sense now!

I've tried the last options you sent, created the variable and selected it from the data pill.

1 - If I use the Path as text, add the URI and the variable from data pill I get this:
code: BadRequest,
message: Expression expected at position 14 in 'PostingDate gt'. CorrelationId: 0a857be3-5129-4966-87ac-71652e8df1e5.

2 - If I use the Path as formula (the =\ and \ are added anyways) )and create a parameter called "$filter" and value as "PostingDate%20gt%20" + a date (I've also tried to not add the Unicode) it ignores the filter... this is what I call (I've also tried removing the "?" from the last character):
Test1.png
This doesn't have the parameter which is on the following screen:
Test2.jpg

From here, the date from the data pill doesn't appear, and when I go to the next screen, it just ignores everything and gets all data. I also noticed that the parameter name is "$Filter" but on this screen it ignores the "$".

I wonder if this is happening because I have a connection set for all my recipes, so in case it's updated, all recipes will also be updated. I'm selecting this connection instead of using the In App HTTP element you mentioned where I would need to add the token,Id, etc.
image.png

I don't know if that rings a bell but I've tried to move the whole call (URL and filter) to the variable, and regardless if I use text or formula, the Path ignores it and shows bad request like I was adding nothing ๐Ÿค”

gary1
Executive Chef III
Executive Chef III

Hi, a few requests:

  1. Can you please post additional screenshots of how you have the action configured? Please use black to redact any sensitive information. Using white makes it difficult to tell if you're missing information or trying to hide it.
  2. Can you also post screenshots of the error messages you're receiving from Workato? This is essential. The Request URL preview may not be the final URL being using in the action/API call, so I don't really trust it.

Some other notes:

  1. Under certain circumstances when you switch between formula mode and text mode, it will add an "=" and some double quotes. This is a bug (as far as I can tell), so when it happens you need to fix it.
  2. The configuration of the connection shouldn't affect the action beyond the authentication.

@gary1 sure! Here are the steps:

Steps:
Steps.png
--------------------------- Text approach:

Variable:
Var.png

Text Path:

Text Path.png

Text Call Preview after I click on "Resume guided setup", I guess it ignores the filter from the data pill here and I can't manually select:

Text Call preview.png

Text Path Error:

Text Path Error.png

I've tried some other variations and I was able to avoid the error, but it ignores the data pill variable for filter and brings all data.

---------------------------------------- Formula Approach:

Formula Path - I've tried some variations here like:
- Adding the filter structure to the string in the path and labeling the parameter as "filter=" or "filter" only.
- Adding the whole path to another variable and have 2 data pills like "Path Data Pill"+"Filter Data Pill".
- Adding the whole filter structure as Parameter name and the filter value as parameter value.
And some others I don't remember now, but all resulted in errors. I was never able to make the Path work in formula mode.

Formula Path.png
Formula Parameter - Here is where I believe there's a bug you mentioned. I've tried manually updating the parameter name where it says "filter" on the screen below to "$filter" or bringing the "=" sign from the value to the name, but nothing worked. Also, if I add my variable from step 2 to the Parameter formula, this screen ignores the variable data pill:
Formula parameter preview.png

Formula Path Preview:
Formula Call preview.png
Formula Path Error - This is the same error I get for all attempts to use the path as a formula:
Formula Path Error.png

Thank you so much for the support, apparently, it's something straightforward but not in this scenario. I couldn't find any other example of API calls using logic resulting in a date to be used as API call filter. This is the last thing I need to make happen, everything else for all other recipes I have is working fine.