Hi,
I have a low code app and I've configured an adhoc data source to get data from an API, however the request to the API doesn't seem to be working properly.
The API endpoint takes a search from date and search to date so I've been constructing my request like this:
var searchfrom = DateTime.Now.AddDays(-1).ToString();
var searchTo = DateTime.Now.ToString();
var URL = ($"http://uklovrtbsswba01:8552/api/deletionlist/deletionLog?SearchDateFrom={searchfrom}&SearchDateTo={searchTo}");
var request = WebRequest.Create(URL);
However the API always returns 400 Bad Request.
If I change my URL to hard typed values like this:
var URL = ($"http://uklovrtbsswba01:8552/api/deletionlist/deletionLog?SearchDateFrom=21/01/2024&SearchDateTo=22/01/2024");
Everything works perfectly and the API returns a 200 response with data.
I'm struggling to see what's going wrong here, why is the first format not returning the expected result, does something happen to it during compilation? Is there a suggested way to insert variables into the URL in this case that will work with Dataminer?
Thanks!
Hi Carl
I'm not so sure if this is really GQI related. It seems to me that this is related to the format of your DateTime.
If you do a .ToString() on your DateTime object, you're not sure that the result will be in a format like '21/01/2024', it might even include timing. Try specifying the DateTime format that your API expects: .ToString("dd/MM/yyyy");
https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tostring?view=net-8.0
Maybe you’ll also need URL encoding. https://learn.microsoft.com/en-us/dotnet/api/system.web.httputility.urlencode?view=net-8.0