cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Dynamic Date parameter in HTTP Request

hsonnenahalli
Contributor
0 Kudos

Dear Experts-

I am working on scenarios in which am using GET functionality of HTTP request to retrieve the data using an API endpoint. I have successfully retrieved historical data but now have I need to get the data for every day which means need to pass a dynamic parameter to the HTTP GET request so that every day am getting the data for that current day. I have used content modifier step and have provided a expression using the date format ${date:now:yyyy-MM-dd} and have provided the same in the HTTP request. The result is 422 error. Please let me know if there are any other ideas that can be implemented so that I can retrieve everyday data.

Any help is appreciated.

Regards


HS

Accepted Solutions (1)

Accepted Solutions (1)

hsonnenahalli
Contributor
0 Kudos

I got this to work! The issue was with the format. Appreciate your input. Yes, I agree that API provider will not see the dynamic parameter but they will just see the dates. So I think need to figure out a way to send the date. I apologize not being more descriptive.

I have not replaced entire string but have replaced only the date factor. My string looks like {"day":["between","${date:now:yyyy-MM-dd}","${date:now:yyyy-MM-dd}"]}. This value is maintained in con1 value in exchange property as content

Please find the screenshot of my configuration below. Before sending the HTTP request I have a content modifier step to send the property.

Thanks for support.

Regards

HS

Answers (1)

Answers (1)

MortenWittrock
Active Contributor

Hi Hari

Based on the HTTP status 422 alone, it sounds like your request could be correctly formatted, but still not make sense to the server. Like a date interval with the lower bound being greater than the upper bound.

I'd suggest that you do all your testing in Postman, until you have a request that works, and then implement that in Cloud Integration. That way you can more easily isolate any problems you encounter.

Regards,

Morten

hsonnenahalli
Contributor
0 Kudos

Yes, I am using postman to execute the query and then use in cloud integration. I have an API request as below which works fine with the condition in POSTMAN and same works as expected.

https://api.localytics.com/v1/query?app_id=ed7fcbcc7491692f2c67a35-30fcc6a4-5833-11e7-dcba-007c928ca240&metrics=users&dimensions=day,new_device&conditions={"day":["between","2018-05-21","2018-05-21"]}

Now the need is instead of sending static date range, I want to send a dynamic parameter so that each time it will pull the current day data. I am using "${date:now:yyyy-MM-dd}" instead of {"day":["between","2018-05-21","2018-05-21"]} in my query and it is not working. I have contacted the localytics support to see they allow dynamic date parameter as I was unable to find any info in their documentation but trying to evaluate different options.


Regards


HS

MortenWittrock
Active Contributor
0 Kudos

Hello again

First off, you will be able to find the complete URL in the log under the key "RealDestinationUrl". Does that match what you expect? Second, try posting a screenshot of your receiver channel configuration.

The API provider will not see a dynamic date parameter; they'll just see a date parameter, regardless of how it's generated on the calling side.

Regards,

Morten

MortenWittrock
Active Contributor
0 Kudos

Also, you should not replace the entire {"day":["between","2018-05-21","2018-05-21"]} part of the query string - only the dates inside it.

Regards,

Morten