Sharepoint Online - UserId.NameId - sharepoint

Hi I have problem with get correct NameId from sharepoint Online.
When I try to get it by CSOM I receive correct guid: user.AadObjectId.NameId (00af4ea3-3f02-4857-abe2-357dd6ccceb2)
but when I request by REST I receive
"UserId": {
"__metadata": {
"type": "SP.UserIdInfo"
},
"NameId": "10030000ae7b8efb",
"NameIdIssuer": "urn:federation:microsoftonline"
}
How can I get correct NameId as Guid by REST API?

Using REST API below.
/_api/web/siteusers/getbyid(25)?$select=AadObjectId

Related

How to put an image thumbnail in Sharepoint list element from Power automate with API Query

Hi everyone i try to achieve to put/update an image thumbnail field from a power automate.
What my flow look like is
receive a http payload with base64image content and image name
Create in site/list/attachement folder the image
So far so good i succefully create an image in my site document folder
i get the thumbnail data for my element with a sharepoint http request
METHODS: GET
URI: _api/web/lists/GetByTitle('<MyListName>')/items(2)?$select=Thumbnail_image
i receive as response
"body": {
"d": {
"__metadata": {
"id": "e160a1f1-6877-4dcd-b913-cc96a3811c37",
"uri": "https://<tenantname>/sites/<sitename>/_api/Web/Lists(guid'e3fae353-d412-400e-a49e-14009935e706')/Items(2)",
"etag": "\"28\"",
"type": "SP.Data.<sitename>ListItem"
},
"Thumbnail_image": "{\"type\":\"thumbnail\",\"fileName\":\"tmp_to_delete_ thumbnail.png\",\"nativeFile\":{},\"fieldName\":\"Thumbnail_image\",\"serverUrl\":\"https://<tenantname>\",\"fieldId\":\"6986c538-e002-489c-afe4-e6004c65d991\",\"serverRelativeUrl\":\"/sites/<sitename>/Lists/e3fae353-d412-400e-a49e-14009935e706/tmp_to_delete_thumbnail2.png\",\"id\":\"eb3be415-caa4-40d7-8ce3-24cbae608163\"}"
}
}
from here i tryed to use a PUT and PATCH method on the Items and replace values and url with those corresponding to my new image but my request failed
how can i from here change or add my image in the thumbnail field?
thanks
Configure your Send an HTTP request to SharePoint action like below:
Body Payload Example:
{
"__metadata": {
"type": "SP.Data.ImageListListItem"
},
"Title": "Power Automate",
"Image": "{\"type\":\"thumbnail\",\"fileName\":\"power-automate.png\",\"nativeFile\":{},\"fieldName\":\"Image\",\"serverUrl\":\"https://contoso.sharepoint.com\",\"fieldId\":\"27bfae8e-6eb8-434a-b266-8b41249d38c1\",\"serverRelativeUrl\":\"/sites/SPConnect/SiteAssets/Lists/dbc6f551-252b-462f-8002-c8f88d0d12d5/power-automate.png\",\"id\":\"eec83dc9-26b5-44cb-8222-64ca4a33fd11\"}"
}
Additional Info: Add/Change image on a SharePoint List image column

Generate itemId when batchUpdating with Forms API

Please what are the constraints in generating an itemId. I generate unique itemId for each item in the form, but the API keeps telling me invalid ID.
https://developers.google.com/forms/api/reference/rest/v1/forms#Item
Please I need help with this
{
"includeFormInResponse": false,
"requests": [
{
"createItem": {
"item": {
"itemId": "4e637fjc",
"description": "First Name",
"questionItem": {
"question": {
"textQuestion": {
"paragraph": false
},
"required": true
}
}
},
"location": {
"index": 0
}
}
},
{
"createItem": {
"item": {
"itemId": "njyf3izr",
"description": "Middle Name",
"questionItem": {
"question": {
"textQuestion": {
"paragraph": false
},
"required": true
}
}
},
"location": {
"index": 1
}
}
},
}
]
When I had tested Google Forms API before, unless I'm mistaken, I had thought that the rule of item ID might be required to be 00000000 to 7fffffff as the hex value. By the way, for example, 0 is used as 00000000.
When I saw your showing request body, you are trying to use 4e637fjc and njyf3izr as the item ID. In the case of these values, the values are not hex values. I thought that by this, an error like Invalid ID occurred.
But, I think that actually, this is not published in the official document. So, I would like to tell this.
Added:
About your following reply,
Do you mean something like this, with Javascript. crypto.randomBytes(256).toString('hex').slice(0, 8)
From your tag, when you want to use Google Apps Script or Node.js, how about the following sample script? Unfortunately, Google Apps Script cannot directly use "crypto". So, I proposed the following sample script.
Sample script:
const res = Math.floor(Math.random() * parseInt("7FFFFFFF", 16)).toString(16).padStart(8, "0");
console.log(res);
In this sample script, the values of 00000000 to 7fffffff are randomly returned.
Missing documentation
I am afraid that since the Forms API is very new there is no documentation about the specific format the ID should have.
I have done a couple of tests with the API and the only thing I was able to figure out is that the ID needs an 8-character-long string to work, otherwise it would not work or would fill out the blank spaces with zeros.
When doing the testing I was also able to find out that sometimes the API would take a specific pattern of letters and numbers, but when changing the numbers and letters it stops working for no reason.
This seems like missing clarification from the documentation, and I would strongly recommend sending feedback about this problem on the API method page. You can do so by clicking the following option at the top right corner of the documentation:
Google tends to check that feedback a lot when talking about missing information. In addition to all that you can also fill out a report in Google's issue tracker so that they investigate the inconsistencies when using the batchUpdate method to update the ID.
References:
Forms Item
Method: forms.batchUpdate

How to include Group cover photo in Group Info Endpoint on Facebook Graph API

I have the following endpoint to retrieve the details of a Facebook group via its id
let groupInfoUrl = `https://graph.facebook.com/${group_id}?access_token=${accessToken}`;
Below is an example of the response I got:
{
"name": "Group Name",
"privacy": "OPEN",
"id": "012345678901234"
}
How can I make the response to also include the Group Cover photo or icon?
Thank you.
You just have to add fields=cover to your query:
let groupInfoUrl = `https://graph.facebook.com/${group_id}?fields=cover&access_token=${accessToken}`;

Microsoft Teams bot finding message sender id

We have built a teams app that can be used in the group chat. So, basically any user can do
#
At the server side, we want to get the sending user and respond to the sent text based on who sent it. The code to get users in the conversation looks like below:
const connector = context.adapter.createConnectorClient(context.activity.serviceUrl);
const response = await connector.conversations.getConversationMembers(context.activity.conversation.id);
functions.logger.log("conversation members are:", response)
The response returns an array of all the users in the conversation with below structure
[
{
"id": "29:1a-Xb7uPrMwC2XqjMEHCC7ytV2xb2VUCqTA-n_s-k5ZyMCTKIL-ku2XkgbE167D_5ZbmVaqQxJGIQ13vypSqu-A",
"name": "Neeti Sharma",
"objectId": "718ab805-860c-43ec-8d4e-4af0c543df75",
"givenName": "Neeti",
"surname": "Sharma",
"email": "xxx#xxxx.xxx",
"userPrincipalName": "xxxx#xxxx.xxx",
"tenantId": "xxx-xx-xx-xxxxxx-x",
"userRole": "user"
},
{
...
}
]
The above response does not indicate who is the sender of the message in the group chat. How do we find that?
I'm not sure the exact syntax for Node (I work mostly in C#), but basically on the context.activity object there is a from property (i.e. context.activity.from), which is of type ChannelAccount (DotNet reference here, but it's very similar for Node). That will give you, at least, Name and AadObjectId. What you're using right now is getConversationMembers, which gives you everyone in the entire Channel, not just that particular message/thread.
turnContext.Activity.From.Id is also unique to each user. You can use that property too. Email is tough to get in any other events than the MembersAdded event.

sms authentication with API REST using templateRoles

I'm trying to send a document using a template with the API REST.
I'm using templateRoles in my JSON and i send the name and the mail of the signer who has the rolename defined in the template.
So i have this part of request :
"templateId":"894848C-26A8-44B4-B08D-D9140B70EB1A",
"templateRoles":[
{
"roleName":"CUSTOMER_SIGNER",
"name":"Test",
"email":"test#test.com",
}
]
Now, i want to use sms authentication for my role CUSTOMER_SIGNER.
But in the doc of REST API, there no option for that.
I have try on the model of send a document without template :
"templateId":"894848C-26A8-44B4-B08D-D9140B70EB1A",
"templateRoles":[
{
"roleName":"CUSTOMER_SIGNER",
"name":"Test",
"email":"test#test.com",
"smsAuthentication":{
"senderProvidedNumbers":[
"+00202156511"
]
},
"requireIdLookup":"true",
"idCheckConfigurationName":"SMS Auth $",
"phoneAuthentication":{
"recipMayProvideNumber":"true"
}
}
]
without success. I don't recieve anything.
Have you an idea to make this?

Resources