Create a rule for AppFabric topic using REST API

Kilitli Create a rule for AppFabric topic using REST API

  • 22 Kasım 2011 Salı 10:22
     
      Kod İçerir

    I am trying to create a rule for an AppFabric Topic subscription using REST API.

    First I create a topic, then I create a subscription and finally I want to create a rule that will filter messages for my subscription.

    I succeeded to create the topic and the subscription but when I sent the PUT request to create the rule I Got a 400 error – "Bad request".

     

    var ruleAddress = string.Format("https://{0}.servicebus.windows.net/{1}/subscriptions/{2}/rules/{3}", serviceNamespace, topicName, subscriptionName, druleName);

             

    WebClient webClient = new WebClient();

    webClient.Headers[HttpRequestHeader.Authorization] = token;

     

    var putData = @"<entry xmlns=""http://www.w3.org/2005/Atom"">
    <title type=""text"">testrule</title>
     <content type=""application/xml""> 
        <RuleDescription xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"">
          <Filter i:type=""SqlFilterExpression"">
                  <SqlExpression>To='myvalue'</SqlExpression>
           </Filter>                                        
        </RuleDescription>
       </content>
     </entry>";
     
     webClient.UploadData(ruleAddress, "PUT"Encoding.UTF8.GetBytes(putData));

     

    Does anyone know where I can find an example that demonstrates how to create a rule using the REST api? Or even better does anyone know why do I get the "Bad request Error"?

     

    Thanks

     

    Manu


    Manu
    • Düzenleyen manukahn 22 Kasım 2011 Salı 10:23
    •  

Tüm Yanıtlar

  • 22 Kasım 2011 Salı 23:11
     
     Yanıt Kod İçerir

    Hi Manu,

    - try the following:

    <entry xmlns='http://www.w3.org/2005/Atom'>              
      <content type='application/xml'>    
        <RuleDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">                 
         <Filter i:type='SqlFilter'>   
            <SqlExpression>To='myvalue'</SqlExpression>
            <CompatibilityLevel>20</CompatibilityLevel>
          </Filter>
         </RuleDescription>
        </content>
     </entry>

     

    Thanks

    Roman

     


    Roman Kiss, MVP Connected System Developer
    • Düzenleyen Roman KissMVP 22 Kasım 2011 Salı 23:14
    • Yanıt Olarak İşaretleyen manukahn 23 Kasım 2011 Çarşamba 09:04
    •