I'm develop an chrome extension for jira which get a data from a DIV element of another website and use the data to raise a jira ticket by my chrome extension automatically.
the issue is when I call below jira api in my code I faced below error
content.js:107 POST http://myjira.com:9090/rest/api/2/issue/ 403 (Forbidden)
but as I checked my request in Post Man app everything is fine and new ticket raise in Jira.
I'm really appreciated if someone can help me to fix the issue.
moreover, I used my personal computer and the jira is on another server.
totally I want to have a extension to integrate a ticketing system with jira, without access to that site.
please have following code.
content.js
$(document).ready(function () {
var key = '';
var summary = 'undefined';
var description = '';
var comment = '';
window.setInterval(function () {
/// call your function here
console.log($('Div1').html());
console.log($('Div2').html());
console.log($('#Div3').html());
console.log($('Div4').html());
key = $('.a span:first').html();
summary = $('#b').html();
description = $('#r'')').html();
comment = $('#u').html();
if (summary == 'undefined') {
return;
}
var data = JSON.stringify({
"fields": {
"project": {
"key": "RTF"
},
"summary": "" + summary + "",
"description": "" + description + "",
"issuetype": {
"self": "http://myjira.com/rest/api/2/issuetype/10111",
"id": "10111",
"description": "Service Request",
"iconUrl": "http:/myjira.com/secure/viewavatar?size=xsmall&avatarId=10720&avatarType=issuetype",
"name": "MS Task (SR)",
"subtask": false,
"avatarId": 10720
},
"customfield_10106": {
"self": "http://myjira.com/rest/api/2/customFieldOption/10476",
"value": "EMAIL",
"id": "10476"
},
"customfield_10129": [
{
"self": "http://myjira.com/rest/api/2/customFieldOption/10450",
"value": "TEST",
"id": "10450"
}
],
"customfield_10188": [
{
"self": "http://myjira.com/rest/api/2/customFieldOption/10469",
"value": "Billing",
"id": "10469"
}
],
"customfield_10180": {
"self": "http://myjira.com/rest/api/2/customFieldOption/11000",
"value": "Support",
"id": "11000"
},
"assignee": {
"self": "http://myjira.com/rest/api/2/user?username=e.pirjahandideh",
"name": "e.jj",
"key": "e.jj",
"emailAddress": "e.jj#jj.com",
"avatarUrls": {
"48x48": "http://www.gravatar.com/avatar/68e54d1c135e85b994eb12cb9a3b7b9b?d=mm&s=48",
"24x24": "http://www.gravatar.com/avatar/68e54d1c135e85b994eb12cb9a3b7b9b?d=mm&s=24",
"16x16": "http://www.gravatar.com/avatar/68e54d1c135e85b994eb12cb9a3b7b9b?d=mm&s=16",
"32x32": "http://www.gravatar.com/avatar/68e54d1c135e85b994eb12cb9a3b7b9b?d=mm&s=32"
},
"displayName": "Emil jj",
"active": true,
"timeZone": "Asia/Tehran"
},
"components": [
{
"self": "http://myjira.com/rest/api/2/component/10071",
"id": "10071",
"name": "RR",
"description": "Managed RR"
}
],
"customfield_10189": {
"self": "http://myjira.com/rest/api/2/customFieldOption/10489",
"value": "RR/IT",
"id": "10489"
}
}
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "myjira.com/rest/api/2/issue/");
xhr.setRequestHeader("authorization", "Basic dasfasegsdfgsdfgsdfg");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.setRequestHeader("postman-token", "c6475a5e-6741-6894-5b8e-2350c7c5a176");
xhr.send(data);
}, 10000);
});
manifest.json
{
"manifest_version": 2,
"name": "Name",
"description": "Description",
"browser_action": {
"default_popup": "popup.html"
},
"background": {
"page": "background.html"
},
"version": "1.0",
"permissions": [
"http://myjira.com/",
"http://ticketing2.com"
],
"content_scripts": [
{
"matches": [ "http://*/*", "https://*/*"],
"js": [
"jquery.js",
"jquery-ui.min.js",
"content.js"
],
"run_at": "document_end",
"all_frames": true
}
]
}
Related
I'm writing an Alexa app and setting up multi-modal responses using the 'RenderDocumentDirective' in the python SDK.
For info I'm using an AWS hosted skill in a lambda function.
I'm using RddAPL to add the APL and RddAPLA to add the APLA.
The APLA works fine. The APL has stopped working and I don't know why. I had this working earlier and now I can't work out what is wrong. There are no error messages in the console.
The APLA template works so this is not a permissions issue and it worked. I just don't know what's changed. If I remove the RddAPL directive then everything works fine.
Can you help me review the APL sections to see if there is an error?
Here is the function setting the apl documents:
import config
if config.vars.APL_SUPPORTED == True:
config.apl.DOCUMENT = 'apl/myAPL.json'
config.apl.APLA_DOCUMENT = 'apl/myAPLA.json'
Here is the function calling the apl documents:
import config
from ask_sdk_model.interfaces.alexa.presentation.apl import (
RenderDocumentDirective as RddAPL)
from ask_sdk_model.interfaces.alexa.presentation.apla import (
RenderDocumentDirective as RddAPLA)
def load_apl_document(file_path):
with open(file_path) as f:
return json.load(f)
def myResponse(handler_input, speak_output):
if config.vars.APL_SUPPORTED == True:
#creates url for video
videoUrl = create_presigned_url("video/myvideo.mp4")
handler_input.response_builder.add_directive(
RddAPL(
token = 'myToken',
document = load_apl_document(config.apl.DOCUMENT),
datasources = {
"videoUrl": videoUrl
}
)
)
#creates url for audio
audioUrl = create_presigned_url("audio/myaudio.mp3")
handler_input.response_builder.add_directive(
RddAPLA(
token = 'myToken',
document = load_apl_document(config.apl.APLA_DOCUMENT),
datasources = {
"speech": speak_output,
"audioUrl": audioUrl
}
)
)
return (
handler_input.response_builder
.set_should_end_session(False)
.response
)
else:
return (
handler_input.response_builder
.speak(speak_output)
.set_should_end_session(False)
.response
)
and these are the associated JSON files:
{
"type": "APL",
"version": "1.8",
"license": "Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: LicenseRef-.amazon.com.-AmznSL-1.0\nLicensed under the Amazon Software License http://aws.amazon.com/asl/",
"settings": {},
"theme": "dark",
"import": [],
"resources": [],
"styles": {},
"onMount": [],
"graphics": {},
"commands": {},
"layouts": {},
"mainTemplate": {
"parameters": [
"payload"
],
"items": [
{
"items": [
{
"source": "${payload.videoUrl}",
"autoplay": true,
"type": "Video",
"width": "100%",
"height": "100%"
}
],
"layoutDirection": "inherit",
"alignItems": "center",
"type": "Container",
"width": "100%",
"height": "100%"
}
]
}
}
{
"type": "APLA",
"version": "0.91",
"mainTemplate": {
"parameters": [
"payload"
],
"item": [
{
"type": "Mixer",
"items": [
{
"type": "Sequencer",
"items": [
{
"type": "Audio",
"description": "The Audio component plays the provided audio file, such as an MP3 file. See docs for more information.",
"source": "soundbank://soundlibrary/a_sound_from_the_library"
},
{
"type": "Speech",
"content": "${payload.speech}"
}
]
},
{
"type": "Audio",
"source": "${payload.audioUrl}",
"duration": "trimToParent",
"filter": [
{
"type": "Volume",
"amount": "50%"
},
{
"type": "FadeOut",
"duration": 2000
}
]
}
]
}
]
}
}
After hours of testing, I realised that you need a file __init__.py in the folder holding the .json apl templates.
My last answer is actually incorrect.
This is the text from the APL for audio dev documentation, which explains how the APL document differs:
Note: For APL for Audio, use the payload parameter to bind the entire datasources object to your document. This is different from APL 1.3 for screen devices, where you can bind the mainTemplate.parameters parameter to the name of the data source instead.
I've therefore changed my code as follows:
The APL .json
{
"type": "APL",
"version": "1.8",
"license": "Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: LicenseRef-.amazon.com.-AmznSL-1.0\nLicensed under the Amazon Software License http://aws.amazon.com/asl/",
"settings": {},
"theme": "dark",
"import": [],
"resources": [],
"styles": {},
"onMount": [],
"graphics": {},
"commands": {},
"layouts": {},
"mainTemplate": {
"parameters": [
"myDocumentData"
],
"items": [
{
"items": [
{
"source": "${myDocumentData.videoUrl}",
"autoplay": true,
"type": "Video",
"width": "100%",
"height": "100%"
}
],
"layoutDirection": "inherit",
"alignItems": "center",
"type": "Container",
"width": "100%",
"height": "100%"
}
]
}
}
and the datasource:
#creates url for video
videoUrl = create_presigned_url("video/myvideo.mp4")
handler_input.response_builder.add_directive(
RddAPL(
token = 'myToken',
document = load_apl_document(config.apl.DOCUMENT),
datasources = {
myDocumentData: {
"videoUrl": videoUrl
}
}
)
)
I've been trying to add filters to my Search Resource Availability api call following this page: Search resource availability API
No matter what I do I can't seem to filter by Organizational Unit.
Here's my http call body:
{
"Version": "3",
"IsWebApi": true,
"Requirement": {
"msdyn_fromdate": "2021-11-01T00:00:00Z",
"msdyn_todate": "2021-11-30T23:59:00Z",
"msdyn_remainingduration": 60,
"msdyn_duration": 60,
"#odata.type": "Microsoft.Dynamics.CRM.msdyn_resourcerequirement"
},
"Settings": {
"ConsiderSlotsWithProposedBookings": false,
"MovePastStartDateToCurrentDate": true,
"#odata.type": "Microsoft.Dynamics.CRM.expando"
},
"ResourceSpecification":{
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"ResourceTypes#odata.type": "Collection(Microsoft.Dynamics.CRM.expando)",
"ResourceTypes": [
{
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"value": "3"
}
],
"Constraints": {
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"OrganizationalUnits#odata.type": "Collection(Microsoft.Dynamics.CRM.expando)",
"OrganizationalUnits":[
{
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"value": "b2054232-a114-ec11-b6e7-000d3a842ab8"
}
]
}
}
}
And here's the response I get:
{
"#odata.context": "https://orga215da53.api.crm3.dynamics.com/api/data/v9.2/$metadata#Microsoft.Dynamics.CRM.msdyn_SearchResourceAvailabilityResponse",
"TimeSlots": [],
"Resources": [],
"Related": {
"#odata.type": "#Microsoft.Dynamics.CRM.expando",
"TimeSlots#odata.type": "#Collection(Microsoft.Dynamics.CRM.crmbaseentity)",
"TimeSlots": [],
"Resources#odata.type": "#Collection(Microsoft.Dynamics.CRM.crmbaseentity)",
"Resources": []
},
"Exceptions": {
"#odata.type": "#Microsoft.Dynamics.CRM.expando"
}
}
But i KNOW that that organization unit exists in CRM.
I tried changing the odata.type to the actual Organization Unit CRM type (msdyn_organizationalunit) but that just gives me an error (An error occurred while validating input parameters: System.ArgumentNullException: Value cannot be null)
What is it that I'm doing wrong?
Thanks!
Good day,
I'm not sure but maybe "Constraints" should be outside "ResourceSpecification" like:
{
"Version": "3",
"IsWebApi": true,
"Requirement": {
"msdyn_fromdate": "2021-11-01T00:00:00Z",
"msdyn_todate": "2021-11-30T23:59:00Z",
"msdyn_remainingduration": 60,
"msdyn_duration": 60,
"#odata.type": "Microsoft.Dynamics.CRM.msdyn_resourcerequirement"
},
"Settings": {
"ConsiderSlotsWithProposedBookings": false,
"MovePastStartDateToCurrentDate": true,
"#odata.type": "Microsoft.Dynamics.CRM.expando"
},
"ResourceSpecification":{
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"ResourceTypes#odata.type": "Collection(Microsoft.Dynamics.CRM.expando)",
"ResourceTypes": [
{
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"value": "3"
}
]
},
"Constraints": {
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"OrganizationalUnits#odata.type": "Collection(Microsoft.Dynamics.CRM.expando)",
"OrganizationalUnits":[
{
"#odata.type": "Microsoft.Dynamics.CRM.expando",
"value": "b2054232-a114-ec11-b6e7-000d3a842ab8"
}
]
}
}
I need to tell alexa to prompt user for input then store that input in a variable to be used in my code.
InvocationName: send mail
Alexa: Tell me mail subject
User: Test email
Alexa: Okay, tell me message body.
User: This is just a sample test
Alexa, okay, tell me receiver email
User: test#gmail.com
Below is my intent schema:
{
"interactionModel": {
"languageModel": {
"invocationName": "send mail",
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "AMAZON.FallbackIntent",
"samples": []
},
{
"name": "AMAZON.NavigateHomeIntent",
"samples": []
},
{
"name": "SendMailIntent",
"slots": [
{
"name": "ReceiverEmail",
"type": "AMAZON.SearchQuery"
}
],
"samples": [
"mail",
"send mail"
]
}
],
"types": []
},
"dialog": {
"intents": [
{
"name": "SendMailIntent",
"confirmationRequired": false,
"prompts": {},
"slots": [
{
"name": "ReceiverEmail",
"type": "AMAZON.SearchQuery",
"confirmationRequired": false,
"elicitationRequired": true,
"prompts": {
"elicitation": "Elicit.Slot.838288524310.965699312002"
}
}
]
}
],
"delegationStrategy": "ALWAYS"
},
"prompts": [
{
"id": "Elicit.Slot.838288524310.965699312002",
"variations": [
{
"type": "PlainText",
"value": "Enter subject"
}
]
}
]
}
}
and below is the code I have been able to come up with:
// sets up dependencies
const Alexa = require('ask-sdk-core');
const i18n = require('i18next');
const languageStrings = require('./languageStrings');
const SendMailHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
// var code = this.event.request.intent.slots.code.value;
//console.log(code)
// checks request type
return request.type === 'LaunchRequest'
|| (request.type === 'IntentRequest'
&& request.intent.name === 'SendMailIntent');
},
handle(handlerInput) {
const speechText = 'Ok. Tell me the mail subject'
const response = handlerInput.responseBuilder
.speak(speechText)
.reprompt(speechText) // <--- Here is our reprompt
.getResponse();
console.log(response)
return response;
},
};
// Omitted default Alexa handlers
const skillBuilder = Alexa.SkillBuilders.custom();
exports.handler = skillBuilder
.addRequestHandlers(
SendMailHandler,
)
.lambda();
You should use dialog management with 2 slots.
As I can see currently you only collect one slot (ReceiverEmail) with dialoge management.
But you need also to create a slot for the text you want to send.
Later in your code you need to check if the dialogue is in status COMPLETED.
See the example https://github.com/alexa/skill-sample-nodejs-petmatch/ or this video: https://www.youtube.com/watch?v=u99WMljnQXI
I try to implement NLog into my .NET Core Api web service.
I want to log to an Oracle database. All works well through an nlog.config XML file.
But the goal is to implement NLog config into appsettings.json and here problem occurs.
I get the error set in title:
LayoutRenderer cannot be found: 'aspnet-user-identity
My config file is like this :
"NLog": {
"autoReload": true,
"throwConfigExceptions": true,
"internalLogLevel": "info",
"internalLogFile": "c:/app/log/dev/internal-appsetting-nlog.txt",
"extensions": {
"NLog.Extensions.Logging": {
"assembly": [
"NLog.Extensions.Logging",
"NLog.Web.AspNetCore"
]
}
},
"variables": {
"var_logdir": "c:/app/log/dev"
},
"default-wrapper": {
"type": "AsyncWrapper",
"overflowAction": "Block"
},
"targets": {
"all-file": {
"type": "File",
"fileName": "${var_logdir}/nlog-all-${shortdate}.log",
"layout": {
"type": "JsonLayout",
"Attributes": [
{
"name": "timestamp",
"layout": "${date:format=o}"
},
{
"name": "level",
"layout": "${level}"
},
{
"name": "logger",
"layout": "${logger}"
},
{
"name": "message",
"layout": "${message:raw=true}"
},
{
"name": "properties",
"encode": false,
"layout": {
"type": "JsonLayout",
"includeallproperties": "true"
}
}
]
}
},
"db": {
"type": "Database",
"commandText": "INSERT INTO logtable (LOGLEVEL,LOGGER,MESSAGE,MACHINENAME,USERNAME,CALLSITE, THREADID,EXCEPTIONMESSAGE,STACKTRACE,SESSIONID) VALUES (:pLEVEL,:pLOGGER,:pMESSAGE,:pMACHINENAME, :pCALLSITE,:pTHREADID,:pEXCEPTIONMESSAGE,:pSTACKTRACE)",
"parameters": [
{
"name": "#pLEVEL",
"layout": "${level}"
},
{
"name": "#pLOGGER",
"layout": "${logger}"
},
{
"name": "#pMESSAGE",
"layout": "${message}"
},
{
"name": "#pMACHINENAME",
"layout": "${machinename}"
},
{
"name": "#pUSERNAME",
"layout": "${aspnet-user-identity}"
},
{
"name": "#pCALLSITE",
"layout": "${callsite:filename=true}"
},
{
"name": "#pTHREADID",
"layout": "${threadid}"
},
{
"name": "#pEXCEPTIONMESSAGE",
"layout": "${exception}"
},
{
"name": "#pSTACKTRACE",
"layout": "${stacktrace}"
},
{
"name": "#pSESSIONID",
"layout": "${aspnet-sessionid}"
}
],
"dbProvider": "Oracle.ManagedDataAccess.Client.OracleConnection, Oracle.ManagedDataAccess",
"connectionString": "xxxxxxxxxxxx"
}
},
"rules": [
{
"logger": "*",
"minLevel": "Trace",
"writeTo": "all-file"
},
{
"logger": "*",
"minLevel": "Trace",
"writeTo": "db"
},
{
"logger": "Microsoft.*",
"maxLevel": "Info",
"final": true
}
]
},
The internal debugger reports:
2019-10-09 16:48:48.6665 Info Adding target AsyncTargetWrapper(Name=all-file)
2019-10-09 16:48:48.7859 Warn Error when setting property 'Layout' on 'NLog.Targets.DatabaseParameterInfo' Exception: System.ArgumentException: LayoutRenderer cannot be found: 'aspnet-user-identity'. Is NLog.Web not included?
at NLog.Config.Factory`2.CreateInstance(String itemName)
at NLog.Layouts.LayoutParser.GetLayoutRenderer(ConfigurationItemFactory configurationItemFactory, String name)
at NLog.Layouts.LayoutParser.ParseLayoutRenderer(ConfigurationItemFactory configurationItemFactory, SimpleStringReader stringReader)
at NLog.Layouts.LayoutParser.CompileLayout(ConfigurationItemFactory configurationItemFactory, SimpleStringReader sr, Boolean isNested, String& text)
at NLog.Layouts.SimpleLayout.set_Text(String value)
at NLog.Internal.PropertyHelper.TryNLogSpecificConversion(Type propertyType, String value, Object& newValue, ConfigurationItemFactory configurationItemFactory)
at NLog.Internal.PropertyHelper.SetPropertyFromString(Object obj, String propertyName, String value, ConfigurationItemFactory configurationItemFactory)
Error occurs on ${aspnet-sessionid}. If I comment out both layout, everything works well.
I found different things on GitHub issue report but all I tried was a fail.
Could someone help?
The unknown aspnet-user-identity is probably an issue with your extensions:
"extensions": [
{ "assembly": "NLog.Extensions.Logging" },
{ "assembly": "NLog.Web.AspNetCore" }
],
Could you try the above suggestion?
P.S. Updated the wiki to include example of multiple "extensions"
I am trying to access the service endpoint setup in my extension code.
The extension is as follows:
{
"manifestVersion": 1,
"id": "vsts-extensions-myExtensions",
"version": "0.5.1",
"name": "xxx Projects Time Entry",
"description": "Record time spent in xxx Projects",
"publisher": "xxx",
"targets": [
{
"id": "Microsoft.VisualStudio.Services"
}
],
"icons": {
"default": "img/logo.png"
},
"contributions":
[
{
"id": "xxTimeEntry",
"type": "ms.vss-dashboards-web.widget",
...
},
{
"id": "service-endpoint",
"description": "Service Endpoint type for xx connections",
"type": "ms.vss-endpoint.service-endpoint-type",
"targets": [ "ms.vss-endpoint.endpoint-types" ],
"properties": {
"name": "xxxyyy",
"displayName": "xx server connection",
"url": {
"displayName": "Server Url",
"helpText": "Url for the xxx server to connect to."
},
"dataSources": [
{
"name": "xxx Projects",
"endpointUrl": "{{endpoint.url}}api/timesheetwidgetprojects",
"resultSelector": "jsonpath:$[*].nm"
}
],
"authenticationSchemes": [
{
"type": "ms.vss-endpoint.endpoint-auth-scheme-basic",
"inputDescriptors": [
{
"id": "username",
"name": "Username",
"description": "Username",
"inputMode": "textbox",
"validation": {
"isRequired": false,
"dataType": "string"
}
},
{
"id": "password",
"name": "Password",
"description": "Password",
"inputMode": "passwordbox",
"isConfidential": true,
"validation": {
"isRequired": false,
"dataType": "string"
}
}
]
}
]
}
}
],
...
The code to access the service endpoint is something like :
VSS.require(["VSS/Service", "VSS/WebApi/RestClient"],
function (VSS_Service, RestClient) {
var webContext = VSS.getWebContext();
var client = VSS_Service.getCollectionClient(DistributedTask.TaskAgentRestClient);
client.getServiceEndpoints(webContext.project.id).then(
function (endpoints) {
alert('endpoints')
}
);
}
);
however I am not using a task and just have my endpoint in the main vss-extension.json.
Any ideas?
Thanks
Martin
Based on the supported scopes, there isn’t the scope for service endpoint, so you can’t do it.
I submit a user voice here: VSTS extension service endpoint scope, you can vote and follow up.
The workaround is that you can call REST API by using JS code with Personal Access Token in your extension.
Simple code to call REST API:
$.ajax({
url: 'https://fabrikam.visualstudio.com/defaultcollection/_apis/projects?api-version=1.0',
dataType: 'json',
headers: {
'Authorization': 'Basic ' + btoa("" + ":" + myPatToken)
}
}).done(function( results ) {
console.log( results.value[0].id + " " + results.value[0].name );
});
The scope has been added now and it is "vso.serviceendpoint"