Azure API Management Operation URL Template - azure

I am trying to create a simple, parameterless, web api endpoint managed by Azure API Management. My question is I when I add a paramaterless operation, what in the world is the URL template supposed to be? My endpoint is http://airport-api2.azurewebsites.net/api/airport. There are no parameters, the service works fine outside of API Management. I created an API Management and want to add this GET to my azurewebsites endpoint. What is the mandatory URL Template value I need to enter into the API Management portal to get this thing to work. The built in echo service uses /resource. I cannot find an example. thanks in advance

Create the API with these parameters
WebService URL : http://airport-api2.azurewebsites.net/api
WebAPi suffix url : whatyouwant
then configure the operation with
operation : /airport
Enjoy!

Related

Azure POST request redirect using Azure services

Hello I am trying to deploy my Azure Machine Learning pipeline with a REST endpoint. My problem is that I was able to generate an endpoint but has some sensitive information in it (ex: subscription id, resource group, etc). How can I generate a URL that forwards the request body to my Azure ML REST endpoint?
also, here is an approach I've done:
Used Application Gateway Redirect (this approach didn't forward the request body. It instead turned my POST request into a GET request when it redirected to the correct URL.)
The issue is raised because of some of the default security headers dependent on REST API and web based. Need to set the REST API CSP HEADER. Check the request and response headers in config file of the web application.

Can I setup a web hook for a Method in Azure Api Management?

So, I have an API in Azure-API-Management, which is attached to a function. I want to expose one the method in API as Web-hook for another application CRM. It will be an inbound web-hook.
Is it possible ?
A webhook endpoint is like any other HTTP endpoint that usually expects a POST request from an external system. So, yes.
Depending on the CRM Application, you could leverage APIMs built-in security features to authenticate the webhook call without having to validate credentials in your function as a bonus for using APIM.

azure api management soap to rest feature

I'm trying to expose my SOAP service as REST using azure API management SOAP to REST feature.
The WS imports, exposes my services and works fine, but all generated REST services are exposed with POST verb. When i try to change to verb GET the method GetUsers, for example, the content does not load (I receive an OK, but without content). When i try keeping the method with the POST verb, the content loads.
Is this possible? Can i change a HTTP verb from a originally SOAP service that was exposed as REST using Azure Management API?
Thanks.
You should be able to resolve that by adding set-method policy, so that when APIM receives GET request it changes method to POST before forwarding it to backend.
Add this to your API Management policy
<set-method>POST</set-method>

Why would my API App swagger be unavailable to my Azure App Service Logic App?

I have created a simple api with a test controller and published it as an Azure Api App. I have public (anonymous) access enabled, the swagger ui works well in the browser and the swagger validates correctly, and I have added to it the default response setting that Logic Apps require.
When I try to add the Api App to my Logic App, however, I encounter a fault: "Error fetching swagger api definition".
If I try to browse the API definition in the portal I encounter another fault "Cannot get the API definition. It may require additional configuration or authentication on the API app."
If I try to download the swagger data from the portal link this fails with Http 400: Bad Request.
What am I missing here and how do I get this simple Api App working in the portal?
Public URI: https://microsoft-apiappf6c70a179b1b408c99e3f2536467ff39.azurewebsites.net
Swagger UI: https://microsoft-apiappf6c70a179b1b408c99e3f2536467ff39.azurewebsites.net/swagger/ui/index
Raw Swagger:
{"swagger":"2.0","info":{"version":"v1","title":"PE.Services.Idml"},"host":"microsoft-apiappf6c70a179b1b408c99e3f2536467ff39.azurewebsites.net:443","schemes":["https"],"paths":{"/api/ToEpl":{"get":{"tags":["ToEpl"],"operationId":"ToEpl_Get","consumes":[],"produces":["application/json","text/json","application/xml","text/xml"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}},"default":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}}},"deprecated":false},"post":{"tags":["ToEpl"],"operationId":"ToEpl_Post","consumes":["application/json","text/json","application/xml","text/xml","application/x-www-form-urlencoded"],"produces":["application/json","text/json","application/xml","text/xml"],"parameters":[{"name":"value","in":"body","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","schema":{"$ref":"#/definitions/Object"}},"default":{"description":"OK","schema":{"$ref":"#/definitions/Object"}}},"deprecated":false}},"/api/ToEpl/{id}":{"get":{"tags":["ToEpl"],"operationId":"ToEpl_Get","consumes":[],"produces":["application/json","text/json","application/xml","text/xml"],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"OK","schema":{"type":"string"}},"default":{"description":"OK","schema":{"type":"string"}}},"deprecated":false},"put":{"tags":["ToEpl"],"operationId":"ToEpl_Put","consumes":["application/json","text/json","application/xml","text/xml","application/x-www-form-urlencoded"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"},{"name":"value","in":"body","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"No Content"}},"deprecated":false},"delete":{"tags":["ToEpl"],"operationId":"ToEpl_Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"204":{"description":"No Content"}},"deprecated":false}},"/api/Values":{"get":{"tags":["Values"],"operationId":"Values_Get","consumes":[],"produces":["application/json","text/json","application/xml","text/xml"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}},"default":{"description":"OK","schema":{"type":"array","items":{"type":"string"}}}},"deprecated":false},"post":{"tags":["Values"],"operationId":"Values_Post","consumes":["application/json","text/json","application/xml","text/xml","application/x-www-form-urlencoded"],"produces":[],"parameters":[{"name":"value","in":"body","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"No Content"}},"deprecated":false}},"/api/Values/{id}":{"get":{"tags":["Values"],"operationId":"Values_GetById","consumes":[],"produces":["application/json","text/json","application/xml","text/xml"],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"200":{"description":"OK","schema":{"type":"string"}},"default":{"description":"OK","schema":{"type":"string"}}},"deprecated":false},"put":{"tags":["Values"],"operationId":"Values_Put","consumes":["application/json","text/json","application/xml","text/xml","application/x-www-form-urlencoded"],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"},{"name":"value","in":"body","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"No Content"}},"deprecated":false},"delete":{"tags":["Values"],"operationId":"Values_Delete","consumes":[],"produces":[],"parameters":[{"name":"id","in":"path","required":true,"type":"integer","format":"int32"}],"responses":{"204":{"description":"No Content"}},"deprecated":false}}},"definitions":{"Object":{"type":"object","properties":{}}}}
I think this is because you have two routes with the same operationId (ToEpl_Get).
There are a few mitigations
Since Swashbuckle derives this from the action name in your api controller…you can change one of your action names…e.g. GetById instead of Get
Alternatively, the way to change operation id is to go to the SwaggerConfig.cs file add add a custom operation filter. The operation filter extension point will give you access to the operation and to change the id.
So sorry for the inconvenience, and we will be making our error reporting better soon.

Get a List from Office365 using REST API

I want to get a SP2013 list and I can't use CSOM. I've registered my app (a cmd test app, not a SP hosted one) on Sharepoint and have a clientId and clientSecret.
But when I submit the Authorize Url that I built:
https://mysite.sharepoint.com/_layouts/15/OAuthAuthorize.aspx?client_id=<myclientId>&scope=list.read&response_type=code&redirect_uri=https%3A%2F%2Fwww.google.com
I get a http403 on fiddler.
or
when I request it from a browser I get redirected to:
https://www.google.com/?error=invalid_scope&error_description=The%20scope%20list%2Eread%20is%20not%20valid%2E
which is my redirect_uri but with the error "invalid scope". I've tried to use the scope uri (instead of the alias) and got the same response.
Note that I'm also authenticaded when I make the request from the browser. Otherwise I get redirected to the login page.
How can I get an access token to make REST requests to Sharepoint?
Here is a longer description of what I'm trying to do:
I’ve got a sharepoint list at https://mysite.sharepoint.com/. (the location is actually: https://mysite.sharepoint.com/_layouts/15/start.aspx#/Lists/TestTasksList)
And I want to query it from an android app. So far I have and android app built using xamarin to create tasks.
I can’t use the client side object model. So the only option is using the Rest Api.
I have tried to create a simple .net cmd line app to query the rest api but I can’t find a way to authenticate. I think I need to use OAuth but even after getting the clientId and clientsecret I can’t manage to make requests. I can’t get an access token.
Most code samples that I found are for sharepoint applications to be deployed in the cloud and they seem to ignore the authentication bit (or just using default credentials).
I managed to authenticate and query the list using the CSOM in a .net cmd app. But I can’t find a way to do it using the rest api.
I know we can use the legacy web services (from SP2010) but that won’t work as a long term solution.
So the bottom line is querying a list in Office 365 from a console app using the REST api.

Resources