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.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive