Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

Error: Request to a downlevel service failed

$
0
0

Hi,

I am trying to create a Service Bus Namespace using the REST APIs [https://msdn.microsoft.com/en-us/library/azure/jj856303.aspx]. Below is my code:

var uri = string.Format("https://management.core.windows.net/{0}/services/ServiceBus/Namespaces/{1}", subscriptionId,
                sericebusToCreate);

var request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "PUT";
request.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + token);
request.Headers.Add("x-ms-version", "2014-10-01");

var requestContent = @"<NamespaceDescription xmlns=""http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance""><Name>" + sericebusToCreate + @"</Name><Region>Southeast Asia</Region><ServiceBusEndpoint>https://configpoc.servicebus.windows.net/</ServiceBusEndpoint>                      <SubscriptionId>My-subscription</SubscriptionId><Critical>false</Critical>              <EventHubEnabled>true</EventHubEnabled>     <NamespaceType>Messaging</NamespaceType></NamespaceDescription>";
var requestBytes = new ASCIIEncoding().GetBytes(requestContent);
request.ContentType = "application/atom+xml";
request.ContentLength = requestBytes.Length;
var requestStream = request.GetRequestStream();
requestStream.Write(requestBytes, 0, requestBytes.Length);

try
{
var response = (HttpWebResponse)request.GetResponse();
using (var stream = new StreamReader(response.GetResponseStream()))
{
//Do something with response
}
catch (WebException ex)
{
var err = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
Console.WriteLine(err);
}

For getting authentication token, I am using [https://msdn.microsoft.com/en-us/library/azure/ee460782.aspx] method. I can confirm that this method works since I am able to use other REST APIs such as Get Namespace.

When I execute the code, I get "Request to a downlevel service failed" error.

I got very little help from internet. It seems like very few people have faced this issue. Can anyone explain me what is causing this issue and how I can solve this?

Regards



Viewing all articles
Browse latest Browse all 1916

Trending Articles