Can't set a test license token in an Outlook addin - outlook

I'm trying to set a test license token in an Outlook add-in. According to the documentation, I have to set it in the SourceLocation in the manifest file:
<Form xsi:type="ItemRead">
<DesktopSettings>
<SourceLocation DefaultValue="https://localhost:3000?et=%3Cr%3E%0A%20%20%3..."/>
<RequestedHeight>250</RequestedHeight>
</DesktopSettings>
</Form>
The problem is, when I try to get the URL query params, it won't work. window.location looks like this:
https://localhost:3000/?et=
Any idea why it's happening?
When I update the source location of the Action ShowTaskpane, it won't start the addin:
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="messageReadTaskPaneUrl" />
</Action>
...
<bt:Url id="messageReadTaskPaneUrl" DefaultValue="https://localhost:3000?et=%3Cr%3E%0A%20%20%...">
If I set it like this, when I start the addin, it says:
Sorry, but we can't start this add-in because it isn't set up properly.
I use the following test token:
<r>
<t
aid="WA907006056"
pid="{4FB601F2-5469-4542-B9FC-B96345DC8B39}"
cid="32F3E7FC559F4F49"
did="{0672BAE9-B41B-48FE-87F1-7F4D3DD3F3B1}"
ts="30"
et="Trial"
ad="2012-01-12T21:58:13Z"
ed="2019-06-30T21:58:13Z"
sd="2012-01-12T00:00:00Z"
test="true"
te="2019-06-30T02:49:34Z" />
<d>VNNAnf36IrkyUVZlihQJNdUUZl/YFEfJOeldWBtd3IM=</d>
</r>
And use the following service to encode the url:
https://www.urlencoder.org/

The problem is with URL encoding. When encoding the token, you have to remove all the new lines. Otherwise, it will throw an error. So, before encoding, take the token...
<r>
<t
aid="WA907006056"
pid="{4FB601F2-5469-4542-B9FC-B96345DC8B39}"
cid="32F3E7FC559F4F49"
did="{0672BAE9-B41B-48FE-87F1-7F4D3DD3F3B1}"
ts="30"
et="Trial"
ad="2012-01-12T21:58:13Z"
ed="2019-06-30T21:58:13Z"
sd="2012-01-12T00:00:00Z"
test="true"
te="2019-06-30T02:49:34Z" />
<d>VNNAnf36IrkyUVZlihQJNdUUZl/YFEfJOeldWBtd3IM=</d>
</r>
and remove all the new lines like this:
<r> <t aid="WA907006056" pid="{4FB601F2-5469-4542-B9FC-B96345DC8B39}" cid="32F3E7FC559F4F49" did="{0672BAE9-B41B-48FE-87F1-7F4D3DD3F3B1}" ts="30" et="Trial" ad="2012-01-12T21:58:13Z" ed="2019-06-30T21:58:13Z" sd="2012-01-12T00:00:00Z" test="true" te="2019-06-30T02:49:34Z" /> <d>VNNAnf36IrkyUVZlihQJNdUUZl/YFEfJOeldWBtd3IM=</d> </r>
Finally encode it and add to all the source locations.

Related

Toast Notification Action: Website not coming to the foreground

Good Day
I am creating toast notifications from within a PowerShell script and there is a "more information" button that I have added as an action.
<toast>
<actions>
<action arguments="http://google.com" content="more information" activationType="protocol" />
<action arguments="dismiss" content="" activationType="system"/>
</actions>
</toast>
This works fine however it launches Microsoft Edge Chromium without bringing it to the foreground. So if you already have Edge open it feels at first glance like clicking the button on the notification did nothing. The page does open, just not in your face like you'd hope when asking for "more information". I am hoping to have it show up on top and right in your face as my users vary WILDLY in skill/knowledge.
I am looking for a solution where I can do one of the following:
Have something in PowerShell know that the user clicked that button and action the request manually with code rather than letting Windows handle it.
Have the button bring the website to the top.
Create a custom protocol that performs the action differently. I read something loose about this however was not able to understand what was meant by it, and it was just an off hand comment with no context, only including it in case it inspires someone more knowledgably then myself.
I thought at first it may be behavior related to Edge itself however typing "http://google.com" into a Windows Run Dialog absolutely brings it to the front. (as I expect it too)
In case its a factor. PowerShell 5.1 is preferred however 7 is an option for me.
Thanks for any help you may be able to provide.
---Addtional Info---
This is for all sites launched from a toast notification using this method. I unfortunately do not have anything to use to test a non custom notification to see if it does the same thing or not.
The XML above is used to create the toast notification. Here is the PowerShell code that might help make more sense of it.
$ToastTitle = "TOAST NOTIFICATION"
$Signature = "From TEAMNAME"
$BannerImage = "C:\temp\toast-test\toast.jpg"
$EventTitle = "Testing Title"
$EventText = "This is where there would normally be info. This is just a test though."
$site = "http://google.com/"
$MoreInfoTitle = "More Information"
$FirstName = (net user $env:USERNAME /domain | Select-String "Full Name").ToString().Split(",")[-1].trim()
if ($FirstName) {
$CustomHello = "$CustomHello $FirstName"
}
#Specify Launcher App ID, the App that will claim ownership of the toast notification, doesn't affect functionality.
$LauncherID = "AppName"
#Load Assemblies
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
#Build XML Template
[xml]$toastTemplate = #"
<toast duration="long" scenario="reminder">
<visual>
<binding template="ToastGeneric">
<text>$CustomHello</text>
<text>$ToastTitle</text>
<text placement="attribution">$Signature</text>
<image placement="hero" src="$BannerImage"/>
<group>
<subgroup>
<text hint-style="title" hint-wrap="true" >$EventTitle</text>
</subgroup>
</group>
<group>
<subgroup>
<text hint-style="body" hint-wrap="true" >$EventText</text>
</subgroup>
</group>
</binding>
</visual>
<audio src="ms-winsoundevent:notification.default"/>
</toast>
"#
[xml]$ToastActionSnooze = #"
<toast>
<actions>
<input id="SnoozeTimer" type="selection" title="Select a Snooze Interval" defaultInput="15">
<selection id="15" content="15 Minutes"/>
<selection id="30" content="30 Minutes"/>
<selection id="60" content="1 Hour"/>
<selection id="120" content="2 Hours"/>
<selection id="240" content="4 Hours"/>
</input>
<action arguments="$site" content="$MoreInfoTitle" activationType="protocol" />
<action activationType="system" arguments="snooze" hint-inputId="SnoozeTimer" content="" id="test-snooze"/>
<action arguments="dismiss" content="" activationType="system"/>
</actions>
</toast>
"#
[xml]$ToastAction = #"
<toast>
<actions>
<action arguments="$site" content="$MoreInfoTitle" activationType="protocol" />
<action arguments="dismiss" content="" activationType="system"/>
</actions>
</toast>
"#
#If the Snooze parameter was passed, add additional XML elements to Toast
If ($Snooze) {
[void]$ToastTemplate.toast.AppendChild($ToastTemplate.ImportNode($ToastActionSnooze.toast.actions, $true))
}
else {
[void]$ToastTemplate.toast.AppendChild($ToastTemplate.ImportNode($ToastAction.toast.actions, $true))
}
#Prepare XML
$ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New()
$ToastXml.LoadXml($ToastTemplate.OuterXml)
#Prepare and Create Toast
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($LauncherID).Show($ToastMessage)```
You nearly had it right. Just take this LauncherId
$LauncherID = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
and use this last line of code:
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($LauncherID).Show($ToastMessage)

Sending a PDF file in a REST Message

I am trying figure this out any help appreciated. Thanks in advance
The service is a file passthrough that picks up a PDF and then uses the BPL code below to create the rest wrapper and sends the stream data. I am not grabbing the stream from the inbound correctly, "request.Stream" or "request.StreamFC" always produces the following error.
Here is what is sent and returned in the message..
request:
*
<Stream>
15#%Library.FileCharacterStream
</Stream>
response:
<Stream>
Unable to load xml from message: Data at the root level is invalid. Line 1, position 1.
</Stream>
-I think my issue is I am not using the right class by using "%GlobalStreamCharacter", Or the raw PDF CDATA inbound I am not handling correctly
set context.RESTMessage.Stream=##class(%GlobalCharacterStream).%New()
I have tried using different Stream types...File, Binary....but no luck
-The general BPL below
/// BPL Definition
X
Data BPL [ XMLNamespace = "http://www.intersystems.com/bpl" ]
{
<process language='objectscript' request='Ens.StreamContainer' response='Ens.Response'
height='2000' width='2000' >
<context>
.....
.....
....
<code name='Create REST Message' xpos='200' ypos='250' >
<![CDATA[
set context.RESTMessage=##class(EnsLib.HTTP.GenericMessage).%New()
set context.RESTMessage.Stream=##class(%GlobalCharacterStream).%New()
set tSC=context.RESTMessage.Stream.Write(request.StreamFC)
set tSC=context.RESTMessage.HTTPHeaders.SetAt("application/xml","Content-Type")
set tSC=context.RESTMessage.HTTPHeaders.SetAt(context.RESTMessage.Stream.Size,"Content-
Length")
set tSC=context.RESTMessage.HTTPHeaders.SetAt("POST","HttpRequest")
]]>
</code>
You can try this code snippet. I got the answer in the community.
<call name='To application Rest' target='To application REST' async='0'>
<request type='EnsLib.REST.GenericMessage' >
<assign property="callrequest.Stream" value='##class(%Stream.GlobalCharacter).%New()'/>
<assign property="status" value='callrequest.Stream.CopyFrom(request.StreamFC)' action="set" />
<assign property="status" value='callrequest.HTTPHeaders.SetAt("application/xml", "Content-Type")' action="set" />
<assign property="status" value='callrequest.HTTPHeaders.SetAt(callrequest.Stream.Size, "Content-Length")' action="set" />
<assign property="status" value='callrequest.HTTPHeaders.SetAt("POST", "HttpRequest")' action="set" />
</request>
</call>

Yii2 REST API IIS Object Moved

I am using Yii2 REST with ActiveController to create a new Pessoa(), on Apache works fine , but on IIS 8 an error occurs.
Does anyone know of any configuration in IIS?
REQUEST
Request URL:http://10.192.1.145/api/pessoa
Request Method:POST
Status Code:201 Created
Remote Address:10.192.1.145
Referrer Policy:no-referrer-when-downgrade
RESPONSE
<head><title>Document Moved</title></head>
<body><h1>Object Moved</h1>This document may be found
here</body>{"id":"21"}
I had a similar issue to this. It seems to be related to FastCGI. Not sure about it. I know it happens when setting response headers to 201 http status code (this line in source code) which get changed by IIS later. If you have access to server try those solutions:
W7 Pro IIS 7.5 overwrites PHP Location: Header (solved)
In my case I had only FTP access to server so I overridden the Create Action by something like what follows to force a 200 status code instead of 201:
public function actions()
{
$actions = parent::actions();
unset($actions['create']);
return $actions;
}
public function actionCreate() {
$model = new Pessoa();
$model->load(Yii::$app->getRequest()->getBodyParams(), '');
if ($model->save() === false && !$model->hasErrors()) {
throw new ServerErrorHttpException('Failed to update the object for unknown reason.');
}
return $model;
}
Just in case somebody else needs to keep the status code and remove only the response part added by IIS, this is what I did to solve my problem. You may need adapt it to your needs, though:
<!-- PS: In my case, i just had a one line HEAD and a one line BODY being added. -->
<outboundRules>
<rule name="Remove the tag HEAD" preCondition="isStatus201">
<match filterByTags="None" pattern="^\<head\>.*?$" />
<action type="Rewrite" value="" />
</rule>
<rule name="Remove the tag BODY" preCondition="isStatus201">
<match filterByTags="None" pattern="^\<body\>.*?\</body\>" />
<action type="Rewrite" value="" />
</rule>
<preConditions>
<preCondition name="isStatus201">
<add input="{RESPONSE_STATUS}" pattern="^201$" />
</preCondition>
</preConditions>
</outboundRules>
Tested in IIS 8.5;
Hope it helps somebody else.
In fact, I was able to optimize the RegEx so that a single rule catches all the lines up the closing body tag:
<outboundRules>
<rule name="Remove injected 201 content" preCondition="Status 201">
<match filterByTags="None" pattern="^(?:.*[\r\n]*)*.*</body>" />
<action type="Rewrite" value="" />
</rule>
<preConditions>
<preCondition name="Status 201" patternSyntax="Wildcard">
<add input="{RESPONSE_STATUS}" pattern="201" ignoreCase="false" />
</preCondition>
</preConditions>
</outboundRules>

Download NuGet from behind a proxy using inline MSBuild Task

I am using the NuGet.targets file from NuGet to automatically download NuGet.exe and then restore the packets in my project.
This was working well, however at work we have a proxy and this method was failing due to a (407) Proxy Authentication Required Exception. I modified the targets file to use the proxy details and although this method works in an application it does not work in the MSBuild Task, the code is identical.
If I hardcode the proxy and my login details it works, when I build my solution NuGet.exe is downloaded and the packages are restored correctly. The problem only appears to be the authentication in the MSBuild task, I have absolutely no idea why. I have attached my modified code.
If anyone can help I'd appreciate it. Thanks
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try
{
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
using(WebClient webClient = new WebClient())
{
webClient.UseDefaultCredentials = true;
webClient.Proxy = WebRequest.GetSystemWebProxy();
webClient.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials;
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
return true;
}
}
catch (Exception ex)
{
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>

Conflict 409 error when creating a Google Shared Contact using API

I'm continually getting a HTTP 409 "Conflict" error when attempting to add a new Google Shared Contact using the API.
I've followed the documentation as closely as possible and have defined the new entry as so:
<atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'>
<atom:category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact' />
<gd:name>
<gd:givenName>Test</gd:givenName>
<gd:familyName>Testerson</gd:familyName>
<gd:fullName>Test Testerson</gd:fullName>
</gd:name>
<atom:content type='text'></atom:content>
<gd:email rel='http://schemas.google.com/g/2005#work' primary='true' address='test.testerson#sample.com.au' displayName='' />
<gd:email rel='http://schemas.google.com/g/2005#home' address='' />
<gd:phoneNumber rel='http://schemas.google.com/g/2005#work' primary='true'>(07) 33331111</gd:phoneNumber>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#mobile'>0411223344</gd:phoneNumber>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#fax'>(07) 33331122</gd:phoneNumber>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#home'></gd:phoneNumber>
<gd:im address='' protocol='http://schemas.google.com/g/2005#GOOGLE_TALK' primary='true' rel='http://schemas.google.com/g/2005#home' />
<gd:structuredPostalAddress rel='http://schemas.google.com/g/2005#work' primary='true'>
<gd:city>Abbey</gd:city>
<gd:street>PO Box 4561</gd:street>
<gd:region>WA</gd:region>
<gd:postcode>6280</gd:postcode>
<gd:country>Australia</gd:country>
<gd:formattedAddress>PO Box 4561, Abbey, WA, 6280, Australia</gd:formattedAddress>
</gd:structuredPostalAddress>
<gd:structuredPostalAddress rel='http://schemas.google.com/g/2005#other'>
<gd:city>Abbey</gd:city>
<gd:street>47 Example Avenue</gd:street>
<gd:region>WA</gd:region>
<gd:postcode>6280</gd:postcode>
<gd:country>Australia</gd:country>
<gd:formattedAddress>47 Example Avenue, Abbey, WA, 6280, Australia</gd:formattedAddress>
</gd:structuredPostalAddress>
<gd:organization rel='http://schemas.google.com/g/2005#other'>
<gd:orgTitle>Guinea Pig</gd:orgTitle>
<gd:orgName>Test Org</gd:orgName>
</gd:organization>
</atom:entry>
I've set up my HTTP request as follows:
lsToken = GetAuthToken()
Set lobjHttp = CreateObject("MSXML2.XMLHTTP")
Call lobjHttp.Open("POST", CS_FEED_DEFAULT, False, "", "")
Call lobjHttp.setRequestHeader("Authorization", "GoogleLogin auth=" + lsToken)
Call lobjHttp.setRequestHeader("Content-type", "application/atom+xml")
Call lobjHttp.Send(lsOut)
In this example CS_FEED_DEFAULT is the shared contact URL and lsOut is my entry as defined above.
After sending this request I get the 409 response and the following response text:
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gContact='http://schemas.google.com/contact/2008' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:gd='http://schemas.google.com/g/2005'>
<id>http://www.google.com/m8/feeds/contacts/test.com.au/base/47e904e10dd27dd2</id>
<updated>2014-09-17T02:08:39.761Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/>
<title type='text'></title>
<content type='text'></content>
<link rel='http://schemas.google.com/contacts/2008/rel#edit-photo' type='image/*' href='https://www.google.com/m8/feeds/photos/media/test.com.au/47e904e10dd27dd2/1B2M2Y8AsgTpgAmY7PhCfg'/>
<link rel='self' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/test.com.au/full/47e904e10dd27dd2'/>
<link rel='edit' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/test.com.au/full/47e904e10dd27dd2/1410919719761001'/>
<gd:email rel='http://schemas.google.com/g/2005#work' address='test.testerson#sample.com.au' primary='true'/>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#work' primary='true'>(07) 33331111</gd:phoneNumber>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#mobile'>0411223344</gd:phoneNumber>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#work_fax'>(07) 33331122</gd:phoneNumber>
</entry>
Can anyone offer me any advice on this issue?
Thanks.
According to the contacts API documentation, "409 error can be returned when there is a different contact with the same email address. As for now, google contacts API does not allow two different contacts to share an email address".
Have you been trying to add the same email address twice?
I had the same error because I forgot to Start my previously stopped SQL instance on GCP.

Resources