Microsoft Graph upload image - azure

I am trying to make a PUT request to https://graph.microsoft.com/v1.0/me/photo/$value
with Microsoft Graph Explorer
But I get an Internal error 500. Am i doing something wrong or is there a problem with the Graph API
{
"error": {
"code": "ErrorInternalServerError",
"message": "An internal server error occurred. The operation failed., The file you chose isn't an image. Please choose a different file.",
"innerError": {
"request-id": "60c801ff-7d83-47a1-9d38-c01a4769ec1b",
"date": "2018-08-08T09:28:18"
}
}

At the current state you can't upload binary files with Microsoft Graph Explorer. Use Postman to upload binary files. Make a PUT request with "User.ReadWrite" as permission and Content-Type: Image/Jpeg.

Related

Cannot upload inside a shared Sharepoint drive, got 'Entity only allows writes with a JSON Content-Type header'

I am trying to upload a simple text document to a sharepoint shared document folder. My account do have write access within this folder.
To acheive that, I'm using the Microsoft Graph API v1.0.
According to the doc, I'm making the following request: PUT https://graph.microsoft.com/v1.0/sites/{site_id}/drive/items/Shared%20Documents/{name_of_folder}:/text.txt:/content
I've set Content-Type to be text/plain and my body is just 'text'.
The Microsoft Graph API send me the following error:
{
"error": {
"code": "BadRequest",
"message": "Entity only allows writes with a JSON Content-Type header.",
"innerError": {
"date": "2021-08-23T08:10:44",
"request-id": "51fcdf1f-d7d0-4585-b712-ddd0197e046e",
...
}
}
}
I've managed to upload a document using PUT /me/drive/items/{parent-id}:/{filename}:/content
Is there something wrong?

How to get a list of channels in Microsoft Teams using MS Graph?

I'm getting the user's token and submitting a request to /me/joinedTeams and get the teams IDs of the user.
For each team id, I want to get a list of available channels by sending a request to /teams/{id}/channels, however i am getting the following error:
{
"error": {
"code": "Forbidden",
"message": "Failed to execute Skype backend request GetThreadS2SRequest.",
"innerError": {
"date": "2021-03-12T07:08:38",
"request-id": "2f1b9408-e7db-4245-be6f-0ec6d67ff160",
"client-request-id": "2f1b9408-e7db-4245-be6f-0ec6d67ff160"
}
}
}
How do I fix this?
After which I want to send a request to /teams/{id}/channels and get drive-id.
And at the end, for each drive-id, get a list of files - /drives/{drive-id}/root/search(q='').
As I said in the comments, this api call does not support personal accounts, you must use a work account.
This is my test result:

Unable to search for a file exploring for Microsoft Graph Explorer

I am trying to integrated with Microsoft Sharepoint files for which i am started working with Microsoft Graph API.
https://graph.microsoft.com/v1.0/sites/XXXXdev.sharepoint.com:/sites/test
It gives me the site id and when i am trying to search for a file with the site id i am getting error
I am able to get the Site ID but unable to search for a file when i am trying with given API.
GET /sites/{site-id}/drive/root/search(q='{search-text}')
GET /sites/87fe5e97-7r8f-400f-90a7-ed9306f8uyu7/drive/root/search(q='change')
Response: 400
{
"error": {
"code": "BadRequest",
"message": "Url specified is invalid.",
"innerError": {
"request-id": "3e63ef7a-ca00-4464-9cfb-1bbfe48d7fee",
"date": "2019-08-13T10:57:59"
}
}
}
The site id return using "https://graph.microsoft.com/v1.0/sites/XXXXdev.sharepoint.com:/sites/test" like this:
xxx.sharepoint.com,7e659ba9-9691-4653-a556-f8a535a6917f,caadc04a-fd57-43e7-9c4b-9cce08050f6b
And search for a file with the site id API as below.
https://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com,7e659ba9-9691-4653-a556-f8a535a6917f,caadc04a-fd57-43e7-9c4b-9cce08050f6b/drive/root/search(q='change')
I suggest you use Graph Explorer to test the Graph API.
As a workaround, we can use SharePoint Search REST API to achieve it.
https://tenant.sharepoint.com/_api/search/query?querytext='change IsDocument:"True"'
SharePoint Search REST API overview

Graph API encounter 400 failed to get drive in china

Before a day, the operation works fine.
https://microsoftgraph.chinacloudapi.cn/v1.0/users/{user_id}/drives
Suddenly, it keeps encounter this error:
{
"error": {
"code": "BadRequest",
"message": "Unable to retrieve user's mysite URL.",
"innerError": {
"request-id": "d50647af-33c2-4503-a6c1-eb046173108c",
"date": "2018-04-03T08:33:58"
}
}
}
I have checked the subscription and APP permission in graph API, all permission is enabled
And I have tested another APP using the same graph API permission which works fine.
Do not know what going wrong here
Thanks you.

Microsoft Graph InTune Beta API's - Unable to add app to app policy

I am attempting to use Intune specific beta Graph APIs to assign apps to an iOS managed app protection policy. I am able to create the app policies using the endpoint documented below:
https://graph.microsoft.io/en-us/docs/api-reference/beta/api/intune_mam_iosmanagedappprotection_create
When created via API, the app "deployedCount" is 0 until specific apps are added in the admin console UI.
Now, I am attempting to retrieve apps added to any policy by API using the endpoint documented below.
https://graph.microsoft.io/en-us/docs/api-reference/beta/api/intune_mam_mobileappidentifierdeployment_list
I get a 400 bad request response that appears to say this endpoint either does not exist or is not responding correctly. This seems unlike if I mistyped an endpoint.
Response I receive:
{
"error": {
"code": "No method match route template",
"message": "No OData route exists that match template ~/entityset/key/navigation with http verb GET for request /MAMAdmin/MAMAdminFEService/managedAppPolicies('T_338de6df-386d-4f1b-a51c-a0d189c61722')/mobileAppIdentifierDeployments.",
"innerError": {
"request-id": "79514f29-4dca-48a5-a2de-5d14138577d7",
"date": "2017-02-08T17:46:52"
}
}
}
Response if I mistyped:
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'asdfasdf'.",
"innerError": {
"request-id": "e86d84ab-f062-4780-af3c-9afae6e7bc82",
"date": "2017-02-08T18:53:29"
}
}
}
Hello this is Alemeshet Alemu from MSFT.
Sorry, the API documentation is a bit out sync. Could you try with $expand?
GET /managedAppPolicies/{managedAppPoliciesId}?$expand=mobileAppIdentifierDeployments
Alemeshet Alemu (MSFT)

Resources