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

External JSON data loading #14

Closed
brianramirez opened this issue Dec 14, 2016 · 4 comments
Closed

External JSON data loading #14

brianramirez opened this issue Dec 14, 2016 · 4 comments

Comments

@brianramirez
Copy link

I am working on deploying a dashboard to my office and have everything from Cyclotron setup and running just fine on our local server, however I can not load JSON data from an external source (i.e Jira) I have verified that the REST API with JIRA is correct and actually provides the JSON data I expect, however when I added the URL to the Data Sources, it never loads anything.

I have verified that JSON data can be read locally by placing a sample.json file in the /cyclotron-site/_public directory and it loads as expected.

What should I be doing to load external JSON data? Am I missing something around the Proxy settings?

@baumandm
Copy link
Collaborator

By default, the HTTP request is sent by the same cyclotron-svc that is loading the dashboard, so that server needs to be able to access your JIRA URL. The proxy settings are there in case you need to use a different instance for connectivity reasons.

Are you using a self-hosted JIRA instance with a self-signed certificate? If so, you might be running into SSL errors. You'll either need to add the root certificate to the config.js file, or set "strictSSL": false in the options property of the Data Source. That looks like this (in JSON):

{
    "name": "jira-datasource",
    "type": "json",
    "options": {
        "strictSSL": "${false}"
    },
    ...
}

If that doesn't help, your best bet would be checking out the Console and the Network tabs of your browser's developer tools. There could be other network issues, or maybe the JSON data is loading but not in the format Cyclotron is expecting.

@brianramirez
Copy link
Author

We use an instance of JIRA hosted on the Atlassian cloud and their REST documentation says that it just needs a Base64 encoded Authentication header. I have also tried it with a JSON source that my company hosts that does not need authentication and I still do not see the JSON output.

I will verify that the macOS server we are running Cyclotron on is capable of seeing these two JSON URL endpoints.

@baumandm
Copy link
Collaborator

From looking at the JIRA Cloud docs, I'm guessing the returned data isn't in the right format and is getting ignored. Cyclotron's standard data format is an array of maps, so you will likely need to reformat the JIRA output slightly using a Post-Processor:

For debugging, can you try adding this to the Post-Processor option in the Data Source:

pp = function(data) {
    console.log("JIRA API Data:");
    console.log(data);
    
    return data;
}

The Post-Processor runs after the Data Source is successfully executed, and has access to the raw data returned (which it can optionally modify). Run the dashboard and open the browser Console, and see if it logs the API response. If the response needs to be modified, you can do it in the Post-Processor, and return the modified version.

For example, https://docs.atlassian.com/jira/REST/cloud/#api/2/search-search returns this:

{
    "expand": "names,schema",
    "startAt": 0,
    "maxResults": 50,
    "total": 1,
    "issues": [
        {
            "expand": "",
            "id": "10001",
            "self": "http://www.example.com/jira/rest/api/2/issue/10001",
            "key": "HSP-1"
        }
    ],
    "warningMessages": [
        "The value 'splat' does not exist for the field 'Foo'."
    ]
}

If you're looking to show a table of issues, you would want to post-process it like this:

pp = function(data) {
    return data.issues;
}

This just returns the inner issues array, which is an array of objects. But you could also do any kind of transformation you need.

@baumandm
Copy link
Collaborator

Closing this one out.. let me know if you're still having issues with it.

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