Custom JIRA connector
I have tried using the inbuild JIRA connector but I believe our businesses JIRA has customfields which means I cant make sense of the data using this connector and get data like this:
Therefore I am trying to build my own custom JIRA connector. I am however experiencing issues with the Authentication part.
Has anyone else managed to get this set up?
current code is :
httprequest.addHeader('Accept' , 'application/json');
httprequest.addHeader('Authorization' , 'Basic ' + btoa(metadata.account.Username + metadata.account.APIToken));
//Make API call
var res = httprequest.get(metadata.account.JIRA_URL+'rest/api/3/myself');
what I get is
'ERROR: Client must be authenticated to access this resource.'
These credentials work in the available connector
thanks
Best Answer
-
Correct Encoding for Basic Auth:
Ensure you are encoding the credentials correctly for Basic Authentication. The btoa function should encode the credentials as username:api_token.For example, if metadata.account.Username is user@example.com and metadata.account.APIToken is your_api_token, the btoa function should encode the string user@example.com:your_api_token.
Correct API Endpoint:
Ensure that the API endpoint metadata.account.JIRA_URL+'rest/api/3/myself' is correct. The base URL should end with a slash (/) if it’s not included in the variable metadata.account.JIRA_URL.Basic Authentication Header Format:
The Basic Authentication header should be formatted as Basic <encoded_credentials>. Make sure there is no extra space or incorrect formatting.Check API Token and Permissions:
Verify that the API token you’re using has the appropriate permissions to access the JIRA API. Also, ensure that the API token is active and has not expired or been revoked.Verify Credentials:
Test the credentials with a REST client (like Postman) to ensure that they work outside your code. This can help isolate whether the issue is with your code or the credentials.Correct URL Encoding:
Ensure that metadata.account.JIRA_URL is properly URL-encoded if necessary.// Create HTTP request
var httprequest = new Request();
httprequest.addHeader('Accept', 'application/json');
// Encode credentials
var credentials = metadata.account.Username + ':' + metadata.account.APIToken;
var encodedCredentials = btoa(credentials);
// Add Authorization header
httprequest.addHeader('Authorization', 'Basic ' + encodedCredentials);
// Make API call
var res = httprequest.get(metadata.account.JIRA_URL + 'rest/api/3/myself');
// Log response
console.log(res);** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0
Answers
-
Correct Encoding for Basic Auth:
Ensure you are encoding the credentials correctly for Basic Authentication. The btoa function should encode the credentials as username:api_token.For example, if metadata.account.Username is user@example.com and metadata.account.APIToken is your_api_token, the btoa function should encode the string user@example.com:your_api_token.
Correct API Endpoint:
Ensure that the API endpoint metadata.account.JIRA_URL+'rest/api/3/myself' is correct. The base URL should end with a slash (/) if it’s not included in the variable metadata.account.JIRA_URL.Basic Authentication Header Format:
The Basic Authentication header should be formatted as Basic <encoded_credentials>. Make sure there is no extra space or incorrect formatting.Check API Token and Permissions:
Verify that the API token you’re using has the appropriate permissions to access the JIRA API. Also, ensure that the API token is active and has not expired or been revoked.Verify Credentials:
Test the credentials with a REST client (like Postman) to ensure that they work outside your code. This can help isolate whether the issue is with your code or the credentials.Correct URL Encoding:
Ensure that metadata.account.JIRA_URL is properly URL-encoded if necessary.// Create HTTP request
var httprequest = new Request();
httprequest.addHeader('Accept', 'application/json');
// Encode credentials
var credentials = metadata.account.Username + ':' + metadata.account.APIToken;
var encodedCredentials = btoa(credentials);
// Add Authorization header
httprequest.addHeader('Authorization', 'Basic ' + encodedCredentials);
// Make API call
var res = httprequest.get(metadata.account.JIRA_URL + 'rest/api/3/myself');
// Log response
console.log(res);** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
wow, thats great thanks. It was the btoa part I had the format wrong on :)
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 731 Beast Mode
- 55 App Studio
- 40 Variables
- 682 Automate
- 175 Apps
- 451 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 122 Manage
- 119 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 107 Community Announcements
- 4.8K Archive