Skip to content

Fix Applications.Filter(Async) methods sending incorrect JSON body format - #85

Draft
seiggy with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-82
Draft

Fix Applications.Filter(Async) methods sending incorrect JSON body format#85
seiggy with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-82

Conversation

Copilot AI commented Aug 29, 2025

Copy link
Copy Markdown

The Applications.Filter and Applications.FilterAsync methods were sending an incorrectly formatted JSON body to the ARI server, which prevented event filtering from working properly.

Problem

When calling these methods with a filter object like:

await client.Applications.FilterAsync(appName, new
{
    allowed = new[]
    {
        new { type = "ChannelCreated" }
    }
});

The library was sending:

{"filter":{"allowed":[{"type":"ChannelCreated"}]}}

But according to the Asterisk ARI documentation, the expected format should be:

{"allowed":[{"type":"ChannelCreated"}]}

This caused the event filter to be ignored, and ARI would continue sending all events regardless of the filter configuration.

Solution

Removed the unnecessary wrapper object from both methods. Changed:

request.AddParameter("application/json", new { filter = filter }, ParameterType.RequestBody);

To:

request.AddParameter("application/json", filter, ParameterType.RequestBody);

This ensures the filter object is serialized directly as the root JSON object, matching the expected ARI API format.

Testing

  • Verified the JSON output now matches the expected format
  • Confirmed complex filters with both allowed and disallowed arrays work correctly
  • Validated that null filter handling remains unchanged
  • All builds and sample projects continue to work without issues

Fixes #82.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI commented Aug 29, 2025

Copy link
Copy Markdown
Author

@seiggy 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

…wrapper

Co-authored-by: seiggy <1055990+seiggy@users.noreply.github.com>
Copilot AI changed the title [WIP] Applications.Filter(Async) sends wrong JSON body Fix Applications.Filter(Async) methods sending incorrect JSON body format Aug 29, 2025
Copilot AI requested a review from seiggy August 29, 2025 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Applications.Filter(Async) sends wrong JSON body

2 participants