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

Hi @camaliontij,
You might have to use the last30Days datapill{can be found in the properties datatree} instead of {last30Days}
Did you try the above step :
I created a variable X which is of DateTime Type and 
in Request URL, I changed it to formula mode and passed it in the following way.

Prudvi_0-1739454778808.jpeg
Regards,
Prudvi

 

Hi @camaliontij,
Please use below formula in your case and let me know if you able to get the required response.

Timezone.PNG
We get (Today - 30 days) = 2025-01-14. Hence, to add time, we need to use to_time and strfTime formula.

Thanks and Regards,
Shivakumara K A

camaliontij
Deputy Chef I
Deputy Chef I

Hi all,

We might be in the right direction but not quite there yet. Here is what I tried:

- Path as Text:
My understanding is that if I need to use the Last30Days formula, I should set the path to Formula as well, otherwise I get the EDM.date error I mentioned before.

Path as Formula:
I've tried changing it to formula and it seems like Workato considers the URL as formula as well, that's why it has colors. In the example below I get this error:

bad URI(is not URI?): "=https://api.businesscentral.dynamics.com/v2.0/(ID)/Production/api/DF/prod/v2.0/Companies(ID)/DFSPIFF... gt {Last30Days}"
WorkatoCall.png

I've tried to create another parameter to hold the URL and add the URL PArameter and Date Parameter to a Formula Path, that didn't work.
Then I've tried adding the URL between " " so it considers it as a String and also replaced spaces to %20 but that didn't work either.

In all cases now I'm getting the "bad URL" error.

Hi @camaliontij,
You might have used a HTTP connection which will have hostname : https://api.businesscentral.dynamics.com
In the path which is enabled as formula mode you need to provide quotes for static value :
"https://api.businesscentral.dynamics.com/v2.0/ID/Production/api/DF/prod/v2.0/Companies(ID)"+{Last30Days}[which is a parameter]
If there are any spaces, use %20 for URL encode.
Regards,
Prudvi


Hi Prudvi,

You are correct about the HTTP and that is what I explained in my last comment. Let me breakdown here:

This is the current API call in the Formula:
"https://api.businesscentral.dynamics.com/v2.0/(ID)/Production/api/DF/prod/v2.0/Companies(ID)/DFSPIFFDetCustLEntrys?$filter=PostingDate%20gt%20"+{Last30Days}

The Last30Days parameter now is like I was advised:
=(today - 30.days).to_time.strftime("%Y-%m-%dT%H:%M:%S") + "Z"

And the result is this error:

bad URI(is not URI?): "=\"https://api.businesscentral.dynamics.com/v2.0/(ID)/Production/api/DF/prod/v2.0/Companies(ID)/DFSPIFF..."+{Last30Days}"

Btw, than you all for the support so far.