Azure API Management


How to create API using Azure API Management REST API in C#


Can Anyone suggest me for creating API that uses Azure API Management REST API in C#. I Tried but not able to call create an API
Thanks in Advance
private static async Task<string> CreateApiTask(string apiId)
{
string requestUrl = string.Format("{0}/apis/{1}?api-version={2}", baseUrl, Guid.NewGuid(), apiVersion);
using (HttpClient httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var request = new HttpRequestMessage(HttpMethod.Put, requestUrl);
request.Headers.Authorization = new AuthenticationHeaderValue(
"SharedAccessSignature",
sharedAccessSignature);
// var model = new RequestBody();
string str = JsonConvert.SerializeObject(new RequestBody());
equest.Content = new StringContent(str, Encoding.UTF8, "application/json");
HttpResponseMessage response = await httpClient.PutAsync(requestUrl, request.Content); //// (requestUrl, model);
string responseBody = await response.Content.ReadAsStringAsync();
return responseBody;
}
}
Error:
{StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Date: Wed, 19 Aug 2015 07:19:34 GMT
WWW-Authenticate: SharedAccessSignature realm=""
Content-Length: 0
}}
Hi, It looks like you are using an invalid SAS in the header. 
Hi,
You need to set the header name as Authorization, See
https://msdn.microsoft.com/en-us/library/azure/dn776326.aspx i.e. for instance
// Define the required headers to specify the API version and operation type.
request.Method = "GET";
request.Headers.Add("Authorization", sharedAccessSignature);
Header name SharedAccessSignature only works for resources like apis.
Kind Regards,
Steef-Jan Wiggers (Microsoft Azure MVP)BizTalk
Hello swapnil,
I am not sure about this but I have doubt in
SharedAccessSignature basic authentication. I suggest you to cross check credentials passed to shared Access Signature.
In the meanwhile I am researching more with regards to your request and I will get back to you with update.
Thank you for understanding.
Regards,
Sunil.HP
Hi, It looks like you are using an invalid SAS in the header. 
Hi,
You need to set the header name as Authorization, See
https://msdn.microsoft.com/en-us/library/azure/dn776326.aspx i.e. for instance
// Define the required headers to specify the API version and operation type.
request.Method = "GET";
request.Headers.Add("Authorization", sharedAccessSignature);
Header name SharedAccessSignature only works for resources like apis.
Kind Regards,
Steef-Jan Wiggers (Microsoft Azure MVP)BizTalk

Related Links

Set a variable with JWT claim as value
Creating a Webservice in Azure
REST Api just heavily changed?
Azure Resource created by/ created at
Developer portal showing various Liquid errors
Is there REST API to Create/Update/Delete API Policies?
Azure Service Fabric Cluster with OWIN Stateless Web api.
eLogic Learning LMS - Configuring the Multi-Language feature with Azure Cognitive Services
APIM instance stuck on "updating" state after upgrading licens
401 error
Mutual Certificate Proxy Authentication
Call Azure Api from website
Azure API Throttling.
API management on Azure Stack?
Developer portal no longer supplying Authorisation code when OAuth2 provider required
Cannot find the authorization header when uses Basic authentication for backend service

Categories

MSDN
Using Forums
HealthVault
Data Platform Developm...
Windows Live Developer
Windows Hardware Devel...
Bing Ads API: Development
Exchange Server
Archived Forums W
OneDrive Development
Archived Forums
Virtualization
C++ Standards, Extensi...
Testing with Visual St...
Application Insights (AI)
Register and Manage Ac...
Windows App Studio Beta
AdSDK Integration & Ad...
Store Engagement Frame...
Windows Desktop Develo...
Windows Desktop Search...
Windows Imaging Compon...
Message Analyzer
Outlook for Developers
Azure Pack
Azure App Service - We...
Azure Search
Azure CDN
Azure Key Vault
Azure Log Analytics
StorSimple
Azure Logic Apps
Cognitive Services
Azure IoT Hub
Azure Time Series Insi...
Team Foundation Server...
BizTalk Server EDI and...
Commerce Server 2009
Microsoft Solver Found...
Scripting
Partnering with Microsoft
Microsoft Robotics - H...
Microsoft Device Emulator
SQL Server Data Access
SQL Service Broker
SQL Server High Availa...
Getting started with S...
SQL Server Data Qualit...
Windows Embedded 8 Sta...
SQL Server 2012 Spatia...
SQL Server 2012 Master...
Live Connect (Archived)
CRM
App Linking
Office Live Basics, Es...
Open Specifications Qu...
Exchange Server Develo...
Microsoft Lync Persist...
Microsoft Unified Comm...
Expression Encoder
Reference Source Serve...
Microsoft Security Dev...
Retired SharePoint Exc...
.NET Framework 4 setup...
.NET StockTrader Sampl...
CAT.NET
CHESS – Find and Repro...
Commerce Server 2002 a...
Installing and Registe...
Microsoft ESP Platform...
Microsoft Security Dev...
Monitor, Alert and Aut...
Network Quality of Ser...
Search Server: Feature...
Small Business Applica...
SyncFx - Feedback [Rea...
SQL Server 2014 SQL To...
SQL Server 2014 High A...
Tools for Windows Stor...
Visual C++ Express 200...
Visual C++ Express Edi...
Visual Studio Team Ser...
Visual Studio 2008 Exp...
Visual Studio 2008 SP1...
Visual Studio Class De...
Visual Studio Lab Mana...
Visual Studio WPF/SL D...
Visual Studio Online "...
WCF Data Services (Pre...
Web Sandbox - General
Building Windows Store...
XML in Visual Studio 2...
Windows Phone Preview ...
Windows IoT
Microsoft R Open
Cortana Skills Kit

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile