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

Can you please show full URL including the query exactly as Workato is sending it?

 

Hi @camaliontij,
HTTPRequest.jpg
Regards,
Prudvi

gary1
Executive Chef III
Executive Chef III

This seems odd to me. Workato should be automatically URL encoding the parameters. I don't think you should be doing it manually in the input fields.

@gary1 I'm sorry I just saw your message asking for the request. Just so we are in the same page, this is what I'm using:
Path as formula:
"https://api.businesscentral.dynamics.com/v2.0/ID/Production/api/DF/prod/v2.0/Companies(ID)/DFSPIFFDe..."{Last30Days}

Parameter:
Name: Last30Days
Value: (today - 30.days)
Type: Date
I get the same error when I try changing it to String, or date_time, or trying the formulas listed in this thread.image.png

Which results in this error:

image.png
If I add the URL from HTTPS, it overrides base URI so it should be fine. But it seems like when I set it to formula, it adds a =\ at the beginning and \ at the end. I've also tried adding + or & between the string and formula, but all goes to the same error.

The URI is correct, if I run it without a filter it shows all records.

gary1
Executive Chef III
Executive Chef III

Ok, this image makes things a bit clearer.

The problem is you're not passing a date or even a date string, you're literally passing the name of your variable "{Last30Days}" as a string. This needs to be fixed. 

In Workato, you don't reference variables as a string, you reference them by using their data pill.

Please follow these instructions. Let us know if you run into any issues.

  • Step 1: Create a variable action 

date_1.jpg

  • Step 2: Add a variable called "last_30_days" and use this formula

date_2.jpg

  • Step 3: Create the HTTP action

date_3.jpg

  • Step 4: Configure the HTTP action like this. This is how to use the variable properly (by using its data pill). Note: Pruvdi might be right that you have to URL-encode the spaces, but let's see if it works without the encoding

date_4.jpg

  • Alternate Step 4: You can also configure the HTTP action like this

date_5.jpg