Unable to update columnDefinition of an existing column in Sharepoint list using graphApi - BadRequest error - microsoft-graph-api

Sample payload:
{
"text": {
"maxLength": 1000
}
}
And my PATCH Url is
https://graph.microsoft.com/v1.0/sites/my-site-id/lists/my-list-id/columns/my-column-id
I am providing the usual headers
Accept: application/json
Content-Type: application/json
And
Authorization: Bearer Token....
I get BadRequest error
{
"error": {
"code": "invalidRequest",
"message": "One of the provided arguments is not acceptable.",
"innerError": {
"code": "badArgument",
"date": "2023-01-30T16:34:49",
"request-id": "b63137f9-fda0-41b7-9549-5952b5c89427",
"client-request-id": "b63137f9-fda0-41b7-9549-5952b5c89427"
}
}
}
I tried adding "propagateChanges": true to the payload and I get slightly different error
{
"error": {
"code": "invalidRequest",
"message": "Invalid request",
"innerError": {
"date": "2023-01-30T16:39:37",
"request-id": "41ca6541-6097-45c6-9418-d1cf57272d2c",
"client-request-id": "41ca6541-6097-45c6-9418-d1cf57272d2c"
}
}
}
Any help is appreciated.
NOTE: I am able to update for e.g. Description of the column, but not the text.maxLength property.

The maximum length of a SharePoint text field type is 255, you cannot set it to 1000. If you try setting the max length to 200 for example instead of 1000, your query should succeed.
To allow longer strings, you have to use the "note" ("multiline text") field type, not "text". This one has a limit of 63,999.
I am not sure if you can change column type using graph api (you cannot as far as I remember, but I am not 100% sure), you may need to re-create that column as "multiline", change manually, use the classic rest api instead of graph api to do it programmatically, or something like a powershell script.

If you have textColumn and allowMultipleLines is set to false then you have one line text column and the maximum length is 255.
It's not possible to change column type from one line text to multiple lines text via Graph API.
Call
PATCH https://graph.microsoft.com/v1.0/sites/my-site-id/lists/my-list-id/columns/my-column-id
{
"text": {
"allowMultipleLines": true,
"appendChangesToExistingText": false,
"linesForEditing": 6,
"textType": "plain"
}
}
Will fail.
You have to create a new column and define it as multiple lines. Define textColumn and set allowMultipleLines to true.
POST https://graph.microsoft.com/v1.0/sites/my-site-id/lists/my-list-id/columns
{
"description": "",
"displayName": "Column XXX",
"enforceUniqueValues": false,
"hidden": false,
"indexed": false,
"name": "My new multiple lines column",
"readOnly": false,
"required": false,
"text": {
"allowMultipleLines": true,
"appendChangesToExistingText": false,
"linesForEditing": 6,
"textType": "plain"
}
}

Related

Microsoft ToDo Graph API is sending broken JSON

I'm getting the response with invalid JSON (brackets aren't closed) when trying to get the MS ToDo task for the user. Also, API sends HTTP status 200 with that response.
Request/response examples:
https://graph.microsoft.com/v1.0/me/todo/lists/:listID/tasks/:taskID
{
"title": "DELETED",
"createdDateTime": "2020-06-17T18:33:44.3228459Z",
"lastModifiedDateTime": "2020-11-27T11:36:55.8037415Z",
"id": "DELETED",
"linkedResources": [
{
"error": {
"code": "InternalServerError",
"message": "Invalid object within the collection response from workload for navigation property linkedResources with declaring type microsoft.graph.todoTask. Expected a JObject, but got Jtoken type - Null",
"innerError": {
"date": "2021-05-14T03:13:36",
"request-id": "5b9445b0-7405-436a-8179-cac92a8af087",
"client-request-id": "5b9445b0-7405-436a-8179-cac92a8af087"
}
}
}
How can I resolve this issue?

Microsoft Graph returns "Internal Server Error" on request?

I am trying to get my Microsoft Teams assignments through Microsoft Graph. I submit this GET request https://graph.microsoft.com/beta/education/me/classes/{id}/assignments as shown in the docs, with my authentication token as a header. However, below is the reply I get. I am doing this with python, however I have also tried from Graph Explorer which yields the same result.
{
"error": {
"code": "InternalServerError",
"message": "Object reference not set to an instance of an object.",
"innerError": {
"date": "2020-09-07T16:44:48",
"request-id": "011086a0-9240-4896-9363-d403a1a0fb05"
}
}
}
Does anybody have any insight? Is this a problem with Microsoft?
You need to remove the /me. The correct URI is https://graph.microsoft.com/beta/education/classes/{id}/assignments.
From the documentation
POST https://graph.microsoft.com/beta/education/classes/11019/assignments
Content-type: application/json
Content-length: 279
{
"dueDateTime": "2014-02-01T00:00:00Z",
"displayName": "Midterm 1",
"instructions": {
"contentType": "text",
"content": "Read chapters 1 through 3"
},
"grading": {
"#odata.type": "#microsoft.education.assignments.api.educationAssignmentPointsGradeType",
"maxPoints": 100
},
"assignTo": {
"#odata.type": "#microsoft.education.assignments.api.educationAssignmentClassRecipient"
},
"status":"draft",
"allowStudentsToAddResourcesToSubmission": true
}

Schema Extensions : "Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'."

I'm currently building an application that requires me to retrieve users from the Graph API depending of a custom property, in that case, extoe82ql2v_test/companyName but so far, the API responded with Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'."
The request to retrieve the extension :
https://graph.microsoft.com/v1.0/schemaExtensions?$filter=id eq 'extoe82ql2v_test'
The result :
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#schemaExtensions",
"value": [
{
"id": "extoe82ql2v_test",
"description": "Extend data for users",
"targetTypes": [
"User"
],
"status": "InDevelopment",
"owner": "d9a847ce-ca03-4779-88d6-c7e4f98297fe",
"properties": [
{
"name": "companyName",
"type": "String"
},
{
"name": "managerMail",
"type": "String"
},
{
"name": "arrivalDate",
"type": "DateTime"
},
{
"name": "expiryDate",
"type": "DateTime"
}
]
}
]
}
The request to retrieve the users depending of extoe82ql2v_test/companyName :
https://graph.microsoft.com/v1.0/users?$select=extoe82ql2v_test,givenName,surname,mail,mobilePhone,department,companyName,accountEnabled&$filter=extoe82ql2v_test/companyName eq 'test'
The result :
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'.",
"innerError": {
"date": "2020-07-24T20:46:51",
"request-id": "639b8131-70dd-4436-b624-88167fe105eb"
}
}
}
The same query with the Microsoft Graph .NET SDK :
var res = await _graphClient.Users.Request()
.Select($"extoe82ql2v_test,givenName,surname,mail,mobilePhone,department,companyName,accountEnabled")
.Filter($"extoe82ql2v_test/companyName eq 'test'").GetAsync()
I don't understand what the issue is as I followed what the official documentation said about filtering custom properties
Any help is greatly appreciated
Edit : Here is how $select without a $filter looks like
Request :
https://graph.microsoft.com/v1.0/users?$select=givenName,surname,mail,mobilePhone,department,companyName,accountEnabled,extoe82ql2v_test
Response :
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(givenName,surname,mail,mobilePhone,department,companyName,accountEnabled,extoe82ql2v_test)",
"value": [
{
"givenName": "Antoine",
"surname": "D",
"mail": "antoine.d#contoso.com",
"mobilePhone": null,
"department": null,
"companyName": null,
"accountEnabled": true,
"extoe82ql2v_test": {
"#odata.type": "#microsoft.graph.ComplexExtensionValue",
"expiryDate": "2020-12-31T00:00:00Z",
"arrivalDate": "2020-07-22T00:00:00Z",
"managerMail": "antoine.d#contoso.com",
"companyName": "test"
}
}
]
}
Edit 2:
I successfully filtered the users with another custom attributes, extoe82ql2v_test/managerMail, it's progress but I still need to apply a filter on extoe82ql2v_test/companyName and make it works
Edit 3:
Filtering on extoe82ql2v_test/expiryDate and extoe82ql2v_test/arrivalDate also works, both of these attributes are useless to filter but at least I know they work. As for extoe82ql2v_test/companyName, I wonder if it is because this attribute exists in both the schema extensions and the User Graph object ?
I just faced the same problem and made it work by adding "$count=true" in the query parameters.
I also noticed it seems to need ConsistencyLevel=eventual in the request header.
For example:
https://graph.microsoft.com/v1.0/users?$filter=CompanyName eq 'xxxx'&$select=id,displayName,CompanyName
Bad Request - 400 - 146ms
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported or invalid query filter clause specified for property 'companyName' of resource 'User'.",
...
}
https://graph.microsoft.com/v1.0/users?$count=true&$filter=CompanyName eq 'xxxx'&$select=id,displayName,CompanyName (with header ConsistencyLevel=eventual)
OK - 200 - 404ms
\o/
(I got the hint by looking at this question Microsoft Graph API cannot filter /users by companyName?)

microsoft graph api assign license giving error

I am trying to assign license to a user with Office 365 business premium skuid but getting following error.
Request body:
{
"addLicenses": [
{
"skuId": "skuid"
}
],
"removeLicenses": []
}
Response
{
"error": {
"code": "Request_BadRequest",
"message": "Another object with the same value for property proxyAddresses already exists.",
"innerError": {
"request-id": "b94663b1-f58f-4e30-a457-3db66a0f0b51",
"date": "2020-03-13T11:22:35"
},
"details": [
{
"target": "proxyAddresses",
"code": "ObjectConflict"
}
]
}
}
But the user whom I am assigning license is unique.
Any help is much appreciated.
I can reproduce your issue via the following steps:
I already have a user account: allen3#tenant.onmicrosoft.com. It has an alias (proxyAddress): allenwu#tenant.onmicrosoft.com.
Now I create a new account through Microsoft Graph API with allenwu#tenant.onmicrosoft.com as the userPrincipalName.
POST https://graph.microsoft.com/v1.0/users
Content-type: application/json
{
"accountEnabled": true,
"displayName": "allent3",
"mailNickname": "allent3",
"userPrincipalName": "allenwu#tenant.onmicrosoft.com",
"passwordProfile" : {
"forceChangePasswordNextSignIn": false,
"password": "password-value"
}
}
The magic happened: the account was created successfully!
But when I assign license to the account allenwu#tenant.onmicrosoft.com with Microsoft Graph API, it gives me the same error as yours.
So I think this error prompt is reasonable. (Although it is unreasonable for the account to be created successfully.)
Please check if your tenant has the same problem as me. Hope it's helpful.

Unknown name \"model\" at 'config': Cannot find field

I'm trying to use Google Cloud speech (v1beta1) to analyse phone calls. I can't find the "model" parameter in the C# client library, so I'm constructing my own json message and sending it. This works:
{
"audio": {
"content": "UklGRiavCAA+P8QAAgA....."
},
"config": {
"languageCode": "nl-NL"
}
}
But when I add the phone_call model like this:
{
"audio": {
"content": "UklGRiavCAA+P8QAAgA....."
},
"config": {
"languageCode": "nl-NL",
"model": "phone_call"
}
}
I get an error:
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"model\" at 'config': Cannot find field.",
"errors": [
{
"message": "Invalid JSON payload received. Unknown name \"model\" at 'config': Cannot find field.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
Why? Accoding to the documentation I believe my request is valid?
Edit: to answer my own question: turns out I was using a wrong url. The correct url is: https://speech.googleapis.com/v1p1beta1/speech:recognize.
I'm sorry to be the bearer of bad news, but it looks like the phone call model is only supported for en-US, and your language is nl-NL:
https://cloud.google.com/speech-to-text/docs/basics
Scroll down to "Selecting Models". "Command and Search" and "Default" are both listed as available for all languages, but "video" and "phone call" are listed as "en-US only".

Resources