Illishar
Illishar

Reputation: 916

Manage windows azure service bus queue with JSON instead of XML

Does anyone know if it's possible to use JSON (instead of the default xml) when dealing with windows azure service bus REST queues?

I have a code sample that will create a queue:

public static string CreateQueue(string queue)
{
    string token = GetToken(issuerName, issuerSecret);

    string baseAddress = GetBaseAddress();

    // Create the URI of the new queue, note that this uses the HTTPS scheme
    string queueAddress = baseAddress + queue;
    WebClient webClient = new WebClient();
    webClient.Headers["Content-Type"] = "application/atom+xml";
    webClient.Headers[HttpRequestHeader.Authorization] = token;

    // Prepare the body of the create queue request
    string putData = @"<entry xmlns=""http://www.w3.org/2005/Atom"">
                                      <title type=""text"">" + queue + @"</title>
                                      <content type=""application/xml"">
                                      <QueueDescription xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"" />
                                          </content>
                                        </entry>";

    byte[] response = webClient.UploadData(queueAddress, "PUT", Encoding.UTF8.GetBytes(putData));

    return Encoding.UTF8.GetString(response);
}

I cannot find any way to create the queue through JSON.

The create queue xml sample is not that bad. But I have to implement this on an embedded client and calls like "get queue" and "list queues" are fairly horrible in xml. I'd like to keep it in json if possible.

Upvotes: 2

Views: 687

Answers (1)

BrentDaCodeMonkey
BrentDaCodeMonkey

Reputation: 5523

Unfortunately, the API only accepts a predefined XML schema. Sorry, I don't think you can accomplish what you're after.

Upvotes: 1

Related Questions