Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help identifying the problem in getting response from a http get

    When I enter user details and click on submit, the swagger UI page should be displayed. But it fails in getting a part of the response. I am new to javascript and am fixing someone else's code. Not sure what is wrong. Lines highlighted in RED are the ones that have null values - and then when a null value's length is accessed i get this error "Uncaught TypeError: Cannot read property 'length' of undefined "

    Code:
        SwaggerApi.prototype.build = function() {
          var _this = this;
          this.progress('fetching damn resource list: ' + this.discoveryUrl);
          console.log("start");
          return $.ajax({ 
        	  url: this.discoveryUrl,
        	  dataType: "json",
        	  headers: {"Authorization": getOauthParameters(this.discoveryUrl, "get")},
        	  success: function(response) {
        		    console.log("response: " + response);
        		    console.log("response apiversion: " + response.apiVersion);
        		    console.log("response basepath: " + response.basePath);
        		    console.log("response resourcepath: " + response.resourcePath);
        		    console.log("response apis: " + response.apis);
        	        var res, resource, _i, _j, _len, _len1, _ref, _ref1;
        	        if (response.apiVersion != null) {
        	          _this.apiVersion = response.apiVersion;
        	        }
        	        if ((response.basePath != null) && jQuery.trim(response.basePath).length > 0) {
        	          _this.basePath = location.protocol + "//" + location.host + response.basePath;
        	          if (_this.basePath.match(/^HTTP/i) == null) {
        	            _this.fail("discoveryUrl basePath must be a URL.");
        	          }
        	          _this.basePath = _this.basePath.replace(/\/$/, '');
        	        } else {
        	          _this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('/'));
        	          log('derived basepath from discoveryUrl as ' + _this.basePath);
        	        }
        	        _this.resources = {};
        	        _this.resourcesArray = [];
        	        if (response.resourcePath != null) {
        	          _this.resourcePath = response.resourcePath;
        	          res = null;
        	          _ref = response.apis;
        	          for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        	            resource = _ref[_i];
        	            if (res === null) {
        	              res = new SwaggerResource(resource, _this);
        	            } else {
        	              res.addOperations(resource.path, resource.operations);
        	            }
        	          }
        	          if (res != null) {
        	            _this.resources[res.name] = res;
        	            _this.resourcesArray.push(res);
        	            res.ready = true;
        	            _this.selfReflect();
        	          }
        	        } else {
        	          _ref1 = response.apis;
        	          console.log("response resource" + response.apis);
        	          console.log("ref1 resource" + _ref1);
        	          console.log("ref1 length" + _ref1.length);
        	          for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
        	            resource = _ref1[_j];
        	            res = new SwaggerResource(resource, _this);
        	            _this.resources[res.name] = res;
        	            _this.resourcesArray.push(res);
        	          }
        	        }
        	        return _this;
        	      },
        	  error: function(error) {
        	        return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.discoveryUrl);
              }});
        };

  • #2
    New to the CF scene
    Join Date
    Jul 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The response I was talking about in the post is an OAuth Authorization Header. Response seems to also have apis parameter that do not get loaded. That's is am auth problem. This is part of a web service that was running with certain user credentials. I had to change the credentials for a change in project. I have changed in all possible places but I get this problem only with new credentials. The old ones still seem fine. So when there is a call

  • #3
    New to the CF scene
    Join Date
    Jul 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How does the oauth signature happen? It matches against what? I have changed the user credentials in places wherever the old ones were. Is there some hidden place or may be server side?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •