We have a little nodejs app pushing a static card into the timeline through the Mirror API.
Once received, a Glass user is going to share the card with his or her Google+ circles. It worked quite well until, I think, the XE18.3 update, when the 'Share' Glass menu suddenly stopped showing G+ Circles as an option to share the card with.
Was this a planned modification to the API, and if so, what is considered now a recommended workflow to share a static card with G+ Circles? Or am I just doing something wrong?
Here is a little snipped how the card is created:
$c.google.auth(user.google_tokenRefresh, function (err, token) {
if (err)
return console.log("ERROR #3 in tracks.add at 'get access_token from google' : " + JSON.stringify(err));
require('/node/node_modules/request').post({
url : 'https://www.googleapis.com/upload/mirror/v1/timeline',
qs : {
uploadType : 'multipart'
},
headers : {
'Authorization' : 'Bearer ' + token.access_token
},
multipart : [{
'Content-Type' : 'application/json; charset=UTF-8',
'body' : JSON.stringify({
menuItems : [{
action : 'SHARE'
}, {
action : 'DELETE'
}
]
})
}, {
'Content-Type' : 'image/png',
'body' : buffer
}
]
}, function (err, resp, rdata2) {
console.log(rdata2);
});
});
Thanks!
I think we figured this out: the root of the problem was in the bug #33 (https://code.google.com/p/google-glass-api/issues/detail?id=33&colspec=ID%20Type%20Status%20Priority%20Owner%20Component%20Summary) when a post-processed picture pushed into the timeline through Mirror API does not get published into G+ due to a bug somewhere in Glass code.
Since we did not have in that static card anything else (like a text for example) but a picture, the content was not considered valid to share to G+ Circles.
Related
I'm using the Wordpress API to update tribe events. The updates are successfully sent (and the change is made) but as a side-effect, any time I do it, the featured image is removed from the post...
wpapi package setup:
Because The Events Calendar has it's own routes that aren't built-in by default in the wpapi package, I use the wp.registerRoute function to set that up. I don't think there's a problem with the way I set that up because otherwise it works.
var WPAPI = require( 'wpapi' );
var wp = new WPAPI({
endpoint: 'https://www.example.com/wp-json',
username: 'username',
password: 'mypassword'
});
wp.tribeevent = wp.registerRoute('tribe/events/v1', '/events/(?P<id>)');
example update:
function showEvent (post_id) {
let data = { "hide_from_listings" : false }
wp.tribeevent().id(post_id).update(data)
}
Haven't been able to find anyone with this issue online, so I'm posting here after exhausting myself trying to get it to work without removing the image... Am I doing this wrong? Is this just a bug? Any suggested workarounds?
I've also tried adding the existing image info into the update data sent, but I get this response when doing so:
{
"error": {
"code": "rest_invalid_param",
"message": "Invalid parameter(s): image",
"data": {
"status": 400,
"params": {
"image": "Invalid parameter."
},
"details": []
}
}
}
Otherwise, when making an update such as { "hide_from_listings" : false }, when the json response comes back, the value of the image key just comes back as false: { "image" : false }
Would greatly appreciate any kind of input on this issue...
I am using Python sharePoint online library -Office365-REST-Python-Client to create new list item. I am able to successfully create new list.
When I try to create new list with Multi-choice field (think it's a custom field), I receive an error.
Payload:
{'__metadata': {'type': 'SP.Data.MyListItem'}, 'Title': 'Task Created by Python Script',
'CategoryDescription': 'This is a test Task created by Python script with the help of Office 365 library.',
'Multichoicefield':{
'__metadata' : {'type' : 'Collection(Edm.String)' },
'results': ['value1', 'value2']
}
}
On running with above payload, receive An open collection property 'Multichoicefield' was found. In OData, open collection properties are not supported.", "400 Client Error: Bad Request for url:
Seems like OData stopped supporting this. Does anyone know how to create with multi-choice field
Open collection properties are supported in more recent versions of OData and the OData libraries. It appears that your ClientContext is using an outdated version of the ODataLibrary.
Check the "Multichoicefield" field settings as the screenshots below.
And try to use the REST API with JavaScript in script editor web part in SharePoint page to check if it works.
<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
var listName="CustomList";
function AddListItem(){
var itemType = GetItemTypeForListName(listName);
var item = {
'__metadata': {'type': itemType },
'Title': 'test',
'Multichoicefield':{
'__metadata' : {'type' : 'Collection(Edm.String)' },
'results': ['value1', 'value2']
}
};
$.ajax({
url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items",
type: "POST",
contentType: "application/json;odata=verbose",
data: JSON.stringify(item),
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data) {
alert("succeeded.");
},
error: function (data) {
alert(JSON.stringify(data));
}
});
}
function GetItemTypeForListName(name) {
return "SP.Data." + name.charAt(0).toUpperCase() + name.split(" ").join("").slice(1) + "ListItem";
}
</script>
<input type="button" onclick="AddListItem()" value="Add"/>
If the JavaScript with REST API works in your environment, you need check the code in python.
I want to add a member to a distribution list. As apparently I can't do this using Microsoft Graph, I am trying to use Azure AD Graph API. I am using Node.js.
I am able to connect to Azure using the adal-node library. I get a token back, send requests, and get responses. (I can list groups, users, etc.).
I am following the Add Members documentation, but I am confused.
In the URL, is object_id the id of the Group to witch I want to add the member?
For myorganization, I am using the tennant_id.
Where do I specify the user data? Should I pass that in the POST? If so, whats' the format?
What is the $links in the URL?
Currently, I am doing this:
request.post(
"https://graph.windows.net/TENNANT_ID_HERE/groups/GROUP_ID_HERE/$links/members?api-version=1.6",
{
headers: {
Authorization: "Bearer " + TOKEN_HERE,
"Content-Type": "application/json"
},
form: { key: "value" } //should I put my user object here?
},
function(err, res, body) {
if (err) {
console.log("err: " + err);
} else {
console.log("res: " + JSON.stringify(res, null, 3));
}
}
);
I get the following error:
{
"odata.error": {
"code": "Request_BadRequest",
"message": {
"lang": "en",
"value": "A supported MIME type could not be found that matches the
content type of the response. None of the supported type(s) 'application/xml, text/xml,
application/json;odata=minimalmetadata;streaming=true, application/json;odata=minimalmetadata;
streaming=false, application/json;odata=minimalmetadata,
application/json;odata=fullmetadata;streaming=true,
application/json;odata=fullmetadata;streaming=false,
application/json;odata=fullmetadata,
application/json;odata=nometadata;streaming=true,
application/json;odata=nometadata;streaming=false,
application/json;odata=nometadata,
application/json;streaming=true,
application/json;streaming=false,
application/json;odata=verbose,
application/json'
matches the content type 'application/x-www-form-urlencoded'."
}
}
}
The short/most important answer is that neither Microsoft Graph or Azure AD Graph API supports distribution lists. From the documentation:
Important: You can only add members to security groups and mail-enabled security groups.
That said, this isn't technically why your call is failing here. Your code is reaching the point where it's failing due to the type of group you're working with. And while it won't help you with managing a distribution list, the following is what is actually happening.
The form: { key: "value" } option is telling request to send the payload as a URL Encoded Form (application/x-www-form-urlencoded). The API requires the payload be sent as JSON (application/json).
To send over JSON, you need to do two things:
Set the json option to true
Set the body value rather than the form value.
The proper code would look something like this:
request.post(
"https://graph.windows.net/{tenant-id}/groups/{group-id}/$links/members?api-version=1.6",
{
headers: {
Authorization: "Bearer " + TOKEN_HERE
},
json: true,
body: JSON.stringify({ url: "https://graph.windows.net/{tenant-id}/directoryObjects/{user-id}" })
},
function(err, res, body) {
if (err) {
console.log("err: " + err);
} else {
console.log("res: " + JSON.stringify(res, null, 3));
}
}
);
The $links parameter in the URI is telling the API that you're providing a link to another resource (in this case, a user record).
we could add member to a group with AD graph API.
post https://graph.windows.net/{tenantId}/groups/{groupobjectid}/$links/members?api-version=1.6
body
{
"url": "https://graph.windows.net/{tenantId}/directoryObjects/{userObjectId}"
}
Test it with Postman
I am trying to get a document file from phone storage when button is pressed and than upload it server. But i don't know which library to use and how to do it.
If you are willing to use a library you have both React-native-fetch-blob or axios.
If React-native-fetch-blob you can do it like this:
RNFetchBlob.fetch('POST', 'http://www.example.com/upload-form', {
Authorization : "Bearer access-token",
otherHeader : "foo",
'Content-Type' : 'multipart/form-data',
}, [
// element with property `filename` will be transformed into `file` in form data
{ name : 'avatar', filename : 'avatar.png', data: binaryDataInBase64},
// custom content type
{ name : 'avatar-png', filename : 'avatar-png.png', type:'image/png', data: binaryDataInBase64},
// part file from storage
{ name : 'avatar-foo', filename : 'avatar-foo.png', type:'image/foo', data: RNFetchBlob.wrap(path_to_a_file)},
// elements without property `filename` will be sent as plain text
{ name : 'name', data : 'user'},
{ name : 'info', data : JSON.stringify({
mail : 'example#example.com',
tel : '12345678'
})},
]).then((resp) => {
// ...
}).catch((err) => {
// ...
})
You will hae to manage to get the file path from libraries like RNFS or even RNFetch blob.
https://github.com/wkh237/react-native-fetch-blob
You can use axios too (https://github.com/mzabriskie/axios), but I don't use it so I can't help you any further.
The difference between both is the way they send the data. RNFB uses the fetch api and goes down to native to get the Base64 encoding, axios works over XMLHttpRequests, which is more likely to be used in internet browsers.
Hope it helps.
I'm currently trying to write a service with the MEAN stack to handle actions on a game. I've followed boiler plates up to the point where I now need to add custom actions.
I have a game model which I can do the usual, save, update, delete on. But I want to add actions like join/leave game. I have tried this currently, for the game service:
window.angular.module('ngff.services.games', [])
.factory('Games', ['$resource',
function($resource){
return $resource(
'games/:gameId/:actionId',
{
gameId: '#_id',
actionId: '#actionId'
},
{
update: {
method: 'PUT',
params: {
actionId: null
}
},
join: {
method: 'POST',
params: {
actionId: 'join'
}
},
leave: {
method: 'POST',
params: {
actionId: 'leave'
}
}
}
);
}]);
Update works correctly, but my other requests always seems to default post to games/:gamesId without adding the actionId on the end. How can I change the location that my form posts to?
I already have the backend worked out, and manually posting to my apis works fine.
I had all this working without angular, but I've never used it before and I'm a little stuck.
Thanks
Ryan