Outlook Mail addin reading body content error - outlook

I'm trying to develop an Outlook mail addin to access the body content of an email.
This is how I'm writing the JavaScript code to according to the Documentation provided by MSDN.
Office.context.mailbox.item.body.getAsync("html", function(result){
$("#mytext3").val(result);
});
When I debug this with chrome, This is the error message I found.
Uncaught Sys.ArgumentException: Sys.ArgumentException: Value does not fall within the expected range.
Parameter name: options
What am I doing wrong?

The call should work (I just tried it), but the result passed to your callback is an object, with the body in result.value.
You could try passing an options parameter, something like:
Office.context.mailbox.item.body.getAsync(
"html",
{ asyncContext: "This is passed to the callback" },
function(result){
$("#mytext3").val(result.value);
}
);

Related

signin/verifyState is not invoked after notifySuccess

notifySuccess doesn't fire signin/veriyState event.
My TeamsMessagingExtensionQuery handler returns something like this:
...
return {
composeExtension: {
type: "auth",
suggestedActions: {
actions: [
{
type: "openUrl",
value: "https://something.com/login/",
title: "Sign in to this app"
}
]
}
}
} as MessagingExtensionResponse;
...
This response shows the searchCmd extension with a sign-in message correctly. On clicking the sign-in, the prompt shows the login page correctly as well, according to the url that was passed in the response.
However, when in the login page I try to pass some test token data using the notifySuccess api,the composeExtension/query command gets invoked (with the state property), but there is no signin/verifyState event getting invoked.
On the login/client side, I am using the following two lines of code:
MSTeams.initialize();
MSTeams.authentication.notifySuccess('<test_token>');
I haven't tried this signin combo (trying to sign in for a message extension), but it seems to me that Teams won't actually invoke "signin/verifyState" in this case, and that's only for a "vanilla" bot authentication flow. In this case, it seems from the docs like you're meant to complete the authentication inside the "composeExtension/query" instead...

AngularJS Ajax get issue

I am a bit new to angular and am scratching my head over this one. my factory console.log's show that the first time through everything is defined correctly, but the factory is for some reason re-evaluating the data I pass it to undefined. Here is my code starting with the html input that is passing the data to the controller then to the factory:
HTML:
<input type="text" placeholder="Enter Channel" ng-model="channel" ng-keydown="$event.which === 13 && cname(channel)"/>
This will send to my controller what is typed in the input field once the enter key is pressed cnam(channel)
Controller and Factory:
angular.module('youtubePlaylistAppApp')
.factory('ytVids', function($http){
return{
getChannel: function(name){
console.log('name: '+name);
var url = 'https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername='+ name +'&key=[my api key]';
console.log(url);
return $http.get(url);
},
getVids: function(channel){
console.log('channel: '+ channel);
return $http.get('https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails&maxResults=50&playlistId='+channel+'&key=[my api key]')
.success(function(response){
//console.log(response.items);
return response.items;
});
}
};
})
.controller('indexCtrl', function ($scope, ytVids) {
$scope.cname = function(channel){
console.log(channel);
ytVids.getChannel(channel);
ytVids.getChannel().success(function(response){
console.log(response);
console.log(response.items[0].contentDetails.relatedPlaylists.uploads);
ytVids.getVids(response.items[0].contentDetails.relatedPlaylists.uploads)
.success(function(data){
console.log(data.items);
$scope.ytChannel = data.items;
});
});
};
});
Here is the output I am seeing in my console dev tools after enter is pressed when typing in the input field:
the first console log console.log(channel); console logs the correct response. If I type "freddiew" and press enter, that is what is logged
Then I pass that into my factory ytVids.getChannel(channel); and console log in the factory console.log('name: '+name); This logs the correct response as in name: freddiew
I then declare a variable var url = and give it the youtube url and concat the channel name with the url
I then console log the variable and get what is expected https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=freddiew&key=[my api key]'
This url works when I have tried it in postman and just hard coding a name in. but passing in the name, the console then spits out some more logs which I dont know why, and it looks like it overides the url I just built out to make the call because this is what is logged from the factory:
name: freddiew
https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=freddiew&key=[my key]
It is then logged after this as undefined and the api call concats undefined with the url and makes the api call with this undefined url
name: undefined
https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=undefined&key=[my key]
forUsername= is where the channel name should go.
anyone know why it is being defined as undefined?
I think you have wrong extra service call.
.controller('indexCtrl', function ($scope, ytVids) {
$scope.cname = function(channel){
console.log(channel);
//ytVids.getChannel(channel); <-- you should remove this & passed channel param in below call
ytVids.getChannel(channel).success(function(response){
console.log(response);
console.log(response.items[0].contentDetails.relatedPlaylists.uploads);
ytVids.getVids(response.items[0].contentDetails.relatedPlaylists.uploads)
.success(function(data){
console.log(data.items);
$scope.ytChannel = data.items;
});
});
};
});

Meteor.http.call Client-side Results Undefined

Consuming Mashape Airbnb API:
The following sits inside the Clients->airbnb.js file.
My Results are undefined. But using the same API, http://jsfiddle.net/ismaelc/FZ5vG/
works just fine.
function getListings(place) {
alert(place);
Meteor.http.call("GET", "https://airbnb.p.mashape.com/s",
{params : {location:place},
headers : {"X-Mashape-Authorization":"ffnGO1suGtJEjqgz4n7ykeuCbDP1hexv"}},
function (error, result) {
$('#listings').html(EJSON.stringify(result.data));
console.log("Status: "+result.statusCode);
console.log("Content: "+result.statusCode);
console.log("data: "+EJSON.stringify(result.data));
console.log("error: "+error.message);
}
);
}
Template.where.events ({
'click #find': function(event){
var place = $('#location').val();
getListings(place);
}
});
My Google Chrome Web Developers Tool is giving me odd HTTP Response.
IMG: Here http://imgur.com/f5u2C7X
Also, I momentarily see my console.log and then it just disappears. Why is this?
You can use the network tab in the chrome dev kit, make sure its already open before you do the request and it should just add on and you can view its text content to find where its all going wrong.
The response tab should have the text it gets back:
Of note is just check your api you might need to use params (HTTP POST params) instead of data (JSON post in the body), e.g {params : {location:place}.

Parse.User.save() doesn't work with Facebook API

I'm using the Facebook SDK to auth a user, and trying to save the user's email to the record after authenticating. However, I keep getting an error on the save call.
The code in question:
Parse.FacebookUtils.logIn({
access_token: authResponse.access_token,
expiration_date: expire_date.toISOString(),
id: response.id
},
{
success: function(user) {
console.log("success!");
user.set({"email":response.email});
user.save();
window.App.navigate("#myplaces", {trigger:true});
},
...
That user.save() call returns error occurred: http://www.parsecdn.com/js/parse-1.1.14.min.js:1: TypeError: 'undefined' is not an object.
According to the docs, I have to be in an authentication call (".logIn", etc.) to perform save(), so I'm wondering if this still works with Parse.FacebookUtils.logIn. Seems like it should.
Ideas as to why this isn't working? The ideal behavior is to log the user in, retrieve information from the FB response, and save that back to the user record on Parse.
Thanks!
Justin
Not sure about this but I had the same problem in Cloud Code and I used success/error callbacks when calling save(...):
user.save(null, {
success: function(){
// Code
},
error: function(){
// Code
}
});
See also here: https://parse.com/questions/saving-a-relation-on-the-current-user

jQuery ajax call does not launch callback when data type is 'script'

For example with jQuery 1.5.2 or smaller this code will log 'ololo' in FireBug console:
$.get(
'some_url',
{ data: 'some_data' },
function() {
console.log('ololo')
},
'script')
Same with .ajax (any type of request), .post
But with jQuery 1.6-1.6.1 the callback does nothing. However, the callback will be launched if data type is anything except 'script'. For example, 'json' or 'html.'
I have not been able to find something concerning this on http://api.jquery.com/jQuery.get/
I think the "script" datatype makes jquery behave like getScript() which
Load a JavaScript file from the server using a GET HTTP request, then
execute it.
To me that means that no callback will be called, as the script will be executed.

Resources