VENTAS: 1-800-867-1389

 locked
Create a rule for AppFabric topic using REST API

    Pregunta

  • 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
    • Editado manukahn martes, 22 de noviembre de 2011 10:23
    martes, 22 de noviembre de 2011 10:22

Respuestas

  • 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
    • Editado Roman Kiss martes, 22 de noviembre de 2011 23:14
    • Marcado como respuesta manukahn miércoles, 23 de noviembre de 2011 9:04
    martes, 22 de noviembre de 2011 23:11