How to make request with sql filter to Service Bus to post a message?

89 Views Asked by At

I have topic with two subscriptions on Service Bus. One of them has this sql filter: enter image description here

The other subscription, this sql filter: enter image description here

When I send a message via Service Bus, the filter works: enter image description here

But when I send a message via request, the message gets "lost" (does not reach any of the only two subscribers).

This is my code to send a message:

private readonly HttpClient _client;

public ServiceBusSender()
{
    _client = new HttpClient();
}

public async Task<HttpResponseMessage> SendAsync(string body)
{
    var request = new HttpRequestMessage(HttpMethod.Post, new Uri($"https://{my-uri}/{my-topic}/messages"));
    
    request.Headers.TryAddWithoutValidation("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
    request.Headers.TryAddWithoutValidation("Authorization", my-auth);
    request.Headers.TryAddWithoutValidation("Host", my-uri);
    request.Headers.TryAddWithoutValidation("IdStatus", "154"); //I have also tried ("IdStatus", "'154'") and it doesnt work
    
    request.Content = new StringContent(body);

    return await _client.SendAsync(request);
}

Any idea what I'm doing wrong to send the filter via request?

1

There are 1 best solutions below

0
zupp On

Just figured it out, just submit with "\"YOURFILTER\"", in my case: "\"154\""