Getting latest clips from a channel

Hello everyone

I’m trying to create a GET request that will return the last clip created on a channel in my C# Application, and I’m struggling with it.

I’ve already read basically all the topics created on the matter on the forums, and I’ve realized there is no “latest” query, which is a bummer.

The relevant code to the query is currently:

var httpClient = new HttpClient();
var startDate = DateTime.Today.AddDays(-7).ToRfc3339String();
var endDate = DateTime.Today.ToRfc3339String();
var request = new HttpRequestMessage(HttpMethod.Get, $“{Config.ChannelId}&first=1&started_at{startDate}&ended_at{endDate}”);

        request.Headers.Add("Authorization", "Bearer " + accessToken);
        request.Headers.Add("Client-Id", clientId);

        var response = httpClient.SendAsync(request).Result;

But it only returns the overall top clip on the channel, even though it was created in 2018.

What am I doing wrong?

Thanks in advance, and have a fantastic day!!


Theres no = between the query params and their values for both started and ended

Oh you’re absolutely right lol. Oversight on my part.

Now it returns bad request, it appears the date is formatted incorrectly somehow.

Thanks for the help!

Yeah that’ll be the nuances of timezones in RFC3339 :smiley:

Should be a Z or a + or a - not a space I believe.

Fixed it in a REALLY ugly way, but I’ll post it here nonetheless if someone is searching for a quick temporary solution to the issue.

If the “started_at” is based on today, simply write:

var startDate = DateTime.UtcNow.ToRfc3339String().Replace(“+00:00”, “Z”);

Again, this hurts me to look at, but for now it’ll have to do I’m afraid.

Thanks again for your help Barry, hope you have a fantastic day <3

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.