Using ArangoDB documentation version 3.3 or version 3.4 for the Getting Started section of Foxx Microservices, I can't get past this error:
Failed to load API definition.
NetworkError when attempting to fetch resource. http://192.168.1.1:8529/_db/_system/_admin/aardvark/foxxes/docs/swagger.json?mount=/getting-started
That error is shown on the API tab of the service. After installing my service according to the tutorial, I get the service's card as described. I click that card and then click the API tab and the above error is shown.
To eliminate typos, I have tried copying and pasting the exact file contents from the ArangoDB documentation and following every step exactly, and I still get the same error.
The Info tab of my newly created getting-started service contains this info:
Author:
Mount: /getting-started
Mode: Development
Version: Unknown
Version License: Unknown License
Path: /var/lib/arangodb3-apps/_db/_system/getting-started/APP
The example contains only two files and they are:
manifest.json
{
"engines": {
"arangodb": "^3.0.0"
},
"main": "index.js"
}
index.js
'use strict';
const createRouter = require('#arangodb/foxx/router');
const router = createRouter();
module.context.use(router);
router.get('/hello-world', function (req, res) {
res.send('Hello World!');
})
.response(['text/plain'], 'A generic greeting.')
.summary('Generic greeting')
.description('Prints a generic greeting.');
The canned demo services, such as the hello-fox example, work correctly. I collected more error information:
Navigating to http://192.168.1.1:8529/getting-started
404: errorMessage "unknown path '/getting-started'"
Navigating to http://192.168.1.1:8529/_db/_system/getting-started
404: errorMessage "unknown path '/getting-started'"
The console also shows:
WARNING File not found "/getting-started": file "" does not exist in "/var/lib/arangodb3-apps/_db/_system/getting-started/APP/files".
The tutorial doesn't indicate another file named getting-started or another location for the two specified files. What am I missing?
This issue was resolved based on the helpful comments by #camba1. There was no problem with Arango, just a problem with me understanding the tutorial. For others in my position, here are the things I did not understand properly and that, when addressed, resolved my problems.
The API tab, in contrast to what the tutorial says, will give the error "Failed to load API definition" even for a correctly working service. Ignore that error message. I am not yet using the API tab at all.
the tutorial refers to two paths, '/hello-world' and '/getting-started'. These are used on the endpoint (URI) and in creating the router like below:
router.get('/hello-world', function (req, res) { ...
The tutorial wasn't as clear as it could have been on this point, but as #camba1 pointed out, the service endpoint would end up incorporating both of those elements:
192.168.1.1:8529/_db/_system/getting-started/hello-world .
this very basic demo is easier and better in my opinion when the router is created without a path:
router.get(function (req, res) {
In this case it defaults to a path of '/'. I think this may avoid confusion for raw beginners like me. The service endpoint then becomes one element simpler. In my case, the endpoint (with Arango running on another computer on the LAN) becomes:
192.168.1.1:8529/_db/_system/getting-started
The tutorial would be improved if it either added a couple extra sentences to explain how the endpoint is constructed, or alternatively, did as I suggested above and simplified things by one step.
Related
I have followed the Tutorial and build the basic CF based nodejs applciation to display all BusinessPartners from my S/4HANA on-premise destination.
function getAllBusinessPartners(): Promise<BusinessPartner[]> {
return BusinessPartner.requestBuilder()
.getAll()
.execute({
destinationName: 'MockServer'
});
}
Destination is configured with the Virtual host from cloud connector.
But after deploying to the Cloud Foundry, i get following error for the GET request
{"message":"Service of type destination is not supported! Consider providing your own transformation function when calling destinationForServiceBinding, like this:\n destinationServiceForBinding(yourServiceName, { serviceBindingToDestination: yourTransformationFunction });","level":"warn","custom_fields":{"package":"core","messageContext":"destination-accessor"},"logger":"sap-cloud-sdk-logger","timestamp":"2020-03-09T18:15:41.856Z","msg":"Service of type destination is not supported! Consider providing your own transformation function when calling destinationForServiceBinding, like this:\n destinationServiceForBinding(yourServiceName, { serviceBindingToDestination: yourTransformationFunction });","written_ts":1583777741856,"written_at":"2020-03-09T18:15:41.856Z"}
The application is already bound to the Destination service as well.
Can someone help me here, what went wrong ? or the approach to use destination is different in the new version of Cloud-SDK ?
After lot of attempts, i have made this to work.
My Observations:
Connectivity service is also required to be bound, when using on-premise S4 backend.
There was no errors in the log, i have made certain modification in the code to use async/await
async function getAllBusinessPartners(): Promise<BusinessPartner[]> {
return await BusinessPartner.requestBuilder()
.getAll()
.execute({
destinationName: 'MockServer'
});
}
After this modification, when I hit the GET request, it gave me the following error:
"Failed to get business partners - get request to http://s4h-scc-basic:500/sap/opu/odata/sap/API_BUSINESS_PARTNER/sap/opu/odata/sap/API_BUSINESS_PARTNER failed!"
Could notice that the suffix after the http://domain:port is twice. One I gave in the destination, and the other VDM adds automatically.
Ideally, this error is supposed to be thrown even before adding async/await.
After removing the suffix from the destination, it started to work.
If your request really does error, what you posted here from your logs is most likely not the reason for the failure. We are aware that this message is confusing and will improve it (https://github.com/SAP/cloud-sdk/pull/32).
Can you check whether there are more errors in your logs? Based on the code you posted and the setup you described, this should work. Do you have a binding to the XSUAA service.
I get the error: "Failed to retrieve function source code" when I try and deploy a function.
This is all from the command line. I am using node 6.11.5 (but in the firebase-admin package.json file in the nodes folder it is says node 6.9.1 is used to download that). I am using firebase-admin#5.8.1 and firebase-functions#0.8.1.
This is the code in my index.js file that I am trying to deploy:
const functions = require('firebase-functions');
exports.helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
});
I have also tried to deploy many different things.
Two interesting things:
- I used to be able to deploy any function without problem. This changed about a month ago and now every function I try gets this error. I can't remember making any change that would be related to this.
- Also I can deploy functions from my computer (with the exact same set up and firebase versions) to other projects in the same google account and different google accounts without any problem.
Thanks
I think you should check your billing settings in google cloud. I got the same problem and after updating billing information then redeploy the function, the error is gone.
I have followed [this][1] link to add swagger to my existing project. I encountered the following error while setting up swagger. Any leads will be highly appreciated.
:xxx\node_modules\swagger-node-express\Common\node\
swagger.js:84
self.appHandler.get(self.resourcePath.replace(self.formatString, self.jsonSuff
ix), resourceListing);
^TypeError: Cannot read property 'get' of null
[1]: https://github.com/shawngong/Swagger-Node-Express-For-Existing-APIs
This error is popping out because of -
var applicationUrl = 'http://localhost:9000'; //application runs properly on this url
swagger.configure(applicationUrl, '1.0.0');//error here
Looking at the line of code in question node-swagger-express it seems as if you need to call :
swagger.setAppHandler(app);
Before the configure call.
I specifically see the maintainer of the project you are using (https://github.com/shawngong/Swagger-Node-Express-For-Existing-APIs) has a commit message related to setAppHandler in his last commit. Perhaps there is now an issue related to it.
I have a ASP.NET Web API implemented as OWIN middleware. I hosted it on azure and now I have a problem using swagger. It is perfectly working on localhost but when I try it on azure I get this:
The way I did my configuration for swagger on the API was to completely remove SwaggerConfig.cs file and add all the configuration into my Startup.cs class as shown here: How to generate documentation using swashbuckle for WebApi 2 with Owin . If it is going to help, I am trying to implement oAuth2 between my API, identity server and client application.
Can you help me find out what is the reason for not getting swagger functionality on Azure?
EDIT: I also tried the solution from here but without success. I went to my API->Properties->Buld tab->Changed to 'Release' configuration->In the output path added the same what was in the 'Debug' configuration and nothing.
My bin folder on Azure:
I had this problem myself when going though this tutorial.
In that tutorial on #3 under "Configure the middle tier to call the data tier" I named my key apiAppURL instead of toDoListDataAPIURL. This caused me to get 500 response codes and
{
"Message": "An error has occurred."
}
in the response body.
I fixed it by updating the following line:
var client = new ApiApp(new Uri(ConfigurationManager.AppSettings["toDoListApiURL"]));
to
var client = new ApiApp(new Uri(ConfigurationManager.AppSettings["apiAppURL"]));
**The change made was to the string at the end of the line. That code can be found in ToDoListController.cs on line 42
Hope this helps someone!
Check your SwaggerConfig.cs file, if you are not included the xml file with your swagger, it works in your azure app services.
c.IncludeXmlComments($#"{System.AppDomain.CurrentDomain.BaseDirectory}\bin\WebApiSwagger.XML");
c.DescribeAllEnumsAsStrings();
I've included these 2 lines of code to show my xml in the swagger, the azure swagger will gone error.
This is late reply but may help someone in future.
I solved this issue this way:
Set XML documentation file path in project settings to : wwwroot\api.xml
Let Swagger know where the file is within ConfigureServices method in
Startup.cs:
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
// Set the comments path for the Swagger JSON and UI.
var xmlFile = "api.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", xmlFile);
c.IncludeXmlComments(xmlPath);
});
You can set different paths but you will get the idea of how to do it from this example.
I am relatively new to MEAN stack development having been working with it for the past few months. I have an issue I am trying to resolve that I have been researching extensively but cannot seem to get to the bottom of.
So, I have a MEAN stack application that I scaffolded using Yeomen. I created a route which has a view that I would like to show a record set using Angulars ng-repeat directive. I get the dataset via an http get call via an Angular service. However, when I run the app using Grunt I get the error:
Error: [$injector:nomod] Module 'Records' is not available!
I have put a reference to the service in my controller:
angular.module('recordsApp').controller('RecordsCtrl', function ($scope, $http, $filter, Records) {
I have also injected into it the app within the app.js file:
angular.module('recordsApp', [
'ngCookies',
'ngResource',
'ngSanitize',
'ngRoute',
'Records'
])
Can anyone please help point me in the right direction here as to what I am missing?
Thank you.
You don't need to include 'Records' module as your module dependancy, as you only have a service called Records in the same module
angular.module('recordsApp', [
'ngCookies',
'ngResource',
'ngSanitize',
'ngRoute'
])