Internal error message when calling a API Gateway based REST API - node.js

Need some help :) I have created a simple AWS API Gateway with a lambda backend just for trying it out. The only response is { "date": "2017-01-01" }, and the only method accepted is GET. When I test the API in the AWS Console it works fine. The response is as expected. But when I try to access it externally I get an Internal error message response. It kind of blows of course. Do I have to setup a elastic IP for this to work? I shouldn't have to add any roles to the API Gateway (I assume) since the role only declares what resources the API Gateway should be allowed to access? Or is there a "external access" role of some kind? Ot do I have to provide any HTTP-header when accessing the API?

Please enable CORS if you accesing API from an external domain. Please see the screenshot below, which shows how to enable CORS

Related

Async IP restricted Logic App with Azure API Management gives authorization error when calling retry url

I'm trying to mask async Logic App with API Management with the retry policy mentioned here.
The Logic App has the Access control configuration set to "Specific IP ranges" (the IP address of the APIM).
The first call to execute the Logic App trigger works well. However the call to get run status (url from the header location) produces the following error:
{
"error": {
"code": "AuthorizationFailed",
"message": "The access to this api is not allowed with a shared access key when the workflow access control configuration has a list of allowed caller IP addresses. Please use the resource management endpoint using an Active Directory access token to access this api."
}
}
When I remove the IP restrictions from the Logic App (by setting Any IP) everything works well. Is there any way to rewrite the call to get run status so it works with IP restrictions on the Logic App ?
This is a current limitation of the API when Access Control via IP Addresses is setup. As the error message mentions, you will have to use the Workflow Runs - Get API instead.
An alternative would be to route all requests to your Logic App via APIM and leveraging policies to re-write the URLs in the response with APIM URLs pointing to a custom endpoint that can fetch the response using the ARM REST API, providing a seamless experience to any client calling the Logic App.

Getting User Anonymous error while accessing api

I am trying to access an api endpoint and I am getting the following error.The api has been built using node and mongo and hosted in aws. We never used AWS Elastic search service.
{
"Message": "User: anonymous is not authorized to perform: es:ESHttpGet on resource: material-definition"
}
When I hit the browser second time without hard refresh then I get the json data. I can't understand the deep cause.
Any suggestion/hint would be highly appreciated.

Built in Azure Iot-Hub endpoints

I'm using IoTHub F1 subscription and facing following problem:
I'm calling REST endpoint for get device list from iothub,
Ex: https://my_iothub_name.azure-devices.net/devices?top=10&api-version=2016-11-14
The above api call is working fine from postman (postman is ApiAgent)
But the problem is when I'm calling same api from browser it's giving me 405 method not allowed error.
I've read about it and it's looks like problem with OPTIONS request from browsers.
Please throw some lights on this issue,
Thank you very much.
I don't think this is currently possible, first because, from what I see, Azure IoT hub REST API does not issue CORS requests (i.e. they don't write in the CORS header access-control-allow-origin), so your browser client can't access it.

How to access the OEmbed Service in Connections Cloud using the IBM SBT?

Using the IBM SBT, one can easily register and endpoint to connect to IBM Connections Cloud. That way it is easily possible to access the APIs provided by IBM Connections using a local URL that is then proxied to the cloud.
Usage can be done using the provided JavaScript or by just requesting a resource from the locally provided endpoint that is connected to the cloud. While this appears to be working for the vast majority of the documented APIs, it does not for the OEmbed API.
Example: If you have a local Java App Container (like IBM Websphere Liberty Profile) that is running a testapp and has a configured endpoint to your Connections Cloud Organization, you may ask that endpoint to retrieve the users profile service document by requesting: https://localhost/testapp/service/proxy/localhost/profiles/atom/profileService.do.This will retrieve the very same resource as you would receive if you request https://apps.na.collabserv.com/profiles/atom/profileService.do directly.
Other APIs work similarly. Unfortunately the OEmbed API does not. That means, if one would request https://apps.na.collabserv.com/connections/opengraph/form/anonymous/api/oembed?maxHeight=180&maxWidth=180&extended=true&url=http%3A%2F%2Fwww.ibm.com the server returns some JSON as described in the spec. In the same seting as above, a call to https://localhost/testapp/service/proxy/localhost/connections/opengraph/form/anonymous/api/oembed?url=http%3A%2F%2Fwww.ibm.com&maxHeight=180&maxWidth=180&extended=true should return the same result but isn't. Instead the server returns an Error 403: SRVE0295E: Error reported: 403 with a HTTP Status 403.
The response is by the way the same result as one would get if he was trying to use the direct URL unauthenticated against the cloud.
Is there anything that needs to be configured in order to use the OEmbed service via SBT?

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.

Resources