Issue with RestAPI for threatAssessmentRequests using Microsoftgraph - microsoft-graph-api

I am trying to connect with https://graph.microsoft.com/v1.0/informationProtection/threatAssessmentRequests
getting below error :
401
{
"error": {
"code": "Unauthorized",
"message": "Required authentication information is either missing or not valid for the resource.",
"innerError": {
"date": "2020-11-06T15:21:22",
"request-id": "8f4d480e-2916-4501-904b-0ca13db9e85e",
"client-request-id": "8f4d480e-2916-4501-904b-0ca13db9e85e"
I am using python3.7 and code looks like :
token ="xyz.dslkdskds_123"
headers = {
"Content-type": "application/json",
"Authorization": "Bearer " + token
}
query1={
"#odata.type": "#microsoft.graph.urlAssessmentRequest","url": "info.cvx.com", "contentType":"url",
"expectedAssessment": "block", "category": "phishing"
}
url="https://graph.microsoft.com/v1.0/informationProtection/threatAssessmentRequests"
r = requests.post(url, headers=headers,data=json.dumps(query1))

Facing the same issue when I run the below query without required permissions in graph explorer
GET https://graph.microsoft.com/v1.0/informationProtection/threatAssessmentRequests
"error": {
"code": "Unauthorized",
"message": "Required authentication information is either missing or not valid for the resource."
But after providing the required permission ThreatAssessment.ReadWrite.All able to get the data

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?

Creating Contact returns ResourceNotFound error

I'm getting an error of ResourceNotFound while integrating and calling POST v1.0/me/contacts:
{
"error": {
"code": "ResourceNotFound",
"message": "Resource could not be discovered.",
"innerError": {
"date": "2021-03-01T15:45:47",
"request-id": "76062d8a-e541-4a52-ae08-9b196dd8e07d",
"client-request-id": "dd8b8c41-22bb-2b78-c926-3063ef313ba0"
}
}
}
I get the same from Graph Explorer:
Note: token is used, API permissions given.
Can anyone please guide/help on 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
}

Getting 500 error for https://graph.microsoft.com/beta/me/profile endpoint

I'm getting a 500 error while invoking https://graph.microsoft.com/beta/me/profile endpoint from
Graph explorer (https://developer.microsoft.com/en-us/graph/graph-explorer). When I check the network tab, I can see the error response as below. Any idea why? I tried resetting my birthdate multiple times from account.microsoft.com but that is still not fixing the timestamp & lastModifiedBy issue
{"#odata.context":"https://graph.microsoft.com/beta/$metadata#users('...')/profile/$entity","id":"profileId","addresses#odata.context":"https://graph.microsoft.com/beta/$metadata#users('...')/profile/addresses","addresses":[],"anniversaries#odata.context":"https://graph.microsoft.com/beta/$metadata#users('...')/profile/anniversaries","anniversaries":[{"type":"birthday","date":"...","allowedAudiences":"me","createdDateTime":"2020-06-30T21:52:30.364606Z","inference":null,"lastModifiedDateTime":"2020-06-30T21:52:30.364606Z"{
"error": {
"code": "InternalServerError",
"message": "The property 'lastModifiedBy[Nullable=False]' of type 'microsoft.graph.identitySet' has a null value, which is not allowed.",
"innerError": {
"date": "2020-06-30T22:15:16",
"request-id": "b9402c6b-297d-4190-a829-8297dae69d9d"
}
}
}{
"error": {
"code": "InternalServerError",
"message": "Unexpected end when deserializing object. Path 'anniversaries[0].lastModifiedDateTime', line 1, position 587.",
"innerError": {
"date": "2020-06-30T22:15:16",
"request-id": "b9402c6b-297d-4190-a829-8297dae69d9d"
}
}
}

branding settings error youtube api

I have to update the featured video of my channel using youtube api.
When I sent PUT request using api explorer of the form
PUT https://www.googleapis.com/youtube/v3/channels?part=brandingSettings&key={YOUR_API_KEY}
{
"brandingSettings": {
"channel": {
"featuredChannelsTitle": "featured channel",
"featuredChannelsUrls": [
"http://www.youtube.com/user/channelname"
]
}
},
"id": "channelId"
}
I am getting response as follows
404 Not Found
- Show headers -
{
"error": {
"errors": [
{
"domain": "youtube.channel",
"reason": "channelNotFound",
"message": "Channel branding options not found.",
"locationType": "parameter",
"location": "id"
}
],
"code": 404,
"message": "Channel branding options not found."
}
}
Please let me know where I am going wrong.
I was giving the wrong channel ID. But now I am trying with the correct Channel Id, and I am getting yet another error message.
Content-Type: application/json
Authorization: Bearer ya29.1.AADtN_X2UP_3BfFvUwAkvLp0d0mk1U-itJNVtWMPEJQU8G7INQ5q-UpI1yNMYniiLQ
X-JavaScript-User-Agent: Google APIs Explorer
{
"id": channelId,
"brandingSettings": {
"channel": {
"featuredChannelsUrls": [
" http://www.youtube.com/user/USERNAME"
],
"featuredChannelsTitle": "Featured Channels"
}
}
}
Response is 400 Bad Request
- Show headers -
{
"error": {
"errors": [
{
"domain": "youtube.channel",
"reason": "brandingValidationError",
"message": "Channel branding validation failed.",
"locationType": "parameter",
"location": "brandingSettings"
}
],
"code": 400,
"message": "Channel branding validation failed."
}
}
If you can provide me a sample request it would be really helpful
As it says in the error message, it couldn't find the channel, make sure you are giving the right channel id.
The way to do it in API, do a channels->list request and use that response object, modify it and put it back. (Most important make sure the id is there and set.)

Resources