Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for AQL request #11

Closed
felipecaldas opened this issue Jun 7, 2017 · 2 comments
Closed

Support for AQL request #11

felipecaldas opened this issue Jun 7, 2017 · 2 comments

Comments

@felipecaldas
Copy link

Hi,

I am trying to extend this library to support the AQL API call. Here's what I've done so far:

ArtifactoryAPI.prototype.AQLSearch = function (searchParams) {
  var deferred = Q.defer();

  var options = {
    url: this.url_ + '/api/search/aql',
    headers: {
      'Authorization': 'Basic ' + this.basicHttpAuth_
    },
    strictSSL: false,
    body: searchParams
  };

  request.post(options, function (error, response) {
    if (error) {
      deferred.reject(error.message);
      return;
    }
    //We expect an OK return code.
    if (response.statusCode !== 200) {
      deferred.reject(response.statusCode);
      return;
    }
    deferred.resolve(JSON.parse(response.body));
  });

  return deferred.promise;
};

Very simple stuff. The API expects a POST request. The searchParams is the AQL itself.
I have tested the AQL string in Postman and it works fine.
But, when using this code, I get a 404.
I fell the issue is with "body", but not sure what else I should do.

Any suggestions?
Thanks

@felipecaldas
Copy link
Author

Alright, my url was wrong.. total noob :)
Here's the fixed one:

url: this.url_ + '/artifactory/api/search/aql',

@cgadam
Copy link
Owner

cgadam commented Jun 8, 2017

@felipecaldas sorry for my late response. Good to know that you solve the issue yourself! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants