The error I'm getting from Microsoft Graph API is this
error = {
"code": "BadRequest",
"innerError": {
"date": "2017-04-10T19:37:08",
"request-id": "973641dd-b150-4406-9f3b-fbcf6f7e5aa1"
},
"message": "The MIME type 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2' requires a '/' character between type and subtype, such as 'text/plain'."
}
I'm able to successfully get from the endpoint https://graph.microsoft.com/v1.0/me/contacts while using POSTman however going the the scribe-java library OAuthRequest I receive this error.
My request is going to the url https://graph.microsoft.com/v1.0/me/contacts with 2 headers.
Authorization -> Bearer [Token]
Content-Type -> application/json
Try setting the "Accept" header explicitly in your request. POSTman may be defaulting you to [Accept=text/html, image/gif, image/jpeg, *; q=.2, /; q=.2]
Hi I was getting same error when I tried to create a new user on AzureAD with graph api.
I solved my issue that I changed my accept header to "Accept":"text/html, application/json".
For your information
It turns out the scribe-java library doesn't setup the request correctly. Switching to apache HttpClient and HttpGet resolved the issue for me.
Related
I am trying to access the sendgrid Rest API using GET https://api.sendgrid.com/v3/contactdb/lists/xxx-xxxx-xxxx-xxxx-xxxx/recipients to get contacts from contacts list
I have also provided headers to rest api call
Content-Type: application/json
Authorization: Bearer SG.xxxxx
Below is the error shown
{
"errors": [
{
"field": null,
"message": "access forbidden"
}
]
}
The documentation for above rest URL is https://docs.sendgrid.com/api-reference/contacts-api-lists/retrieve-all-recipients-on-a-list
Am I missing something?
I send a request to https://www.googleapis.com/batch/youtube/v3, but I get a 404 anyway. Perhaps I am sending the request incorrectly, but most likely the endpoint is not working.
As well as, I use Postman to test with next creds:
1. POST request to https://www.googleapis.com/batch/youtube/v3.
2. Set "Content-type" header to multipart/mixed.
3. Add raw text body with as HTTP:
GET https://www.googleapis.com/youtube/v3/channels?part=snippet&id=2222222&key=* HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=UTF-8
GET https://www.googleapis.com/youtube/v3/channels?part=snippet&id=1111111&key=* HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=UTF-8
Any suggestions for NodeJS?
YouTube Data API version 3 does support batch processing only of the following form:
Batch processing – The v3 API supports one of the batch processing use cases that the v2 API had supported. The v3 API's channels.list, channelSections.list, guideCategories.list, playlistItems.list, playlists.list, subscriptions.list, videoCategories.list, and videos.list methods all support an id parameter, which can be used to specify a comma-delimited list of IDs (video IDs, channel IDs, etc.). Using those methods, you can retrieve a list of multiple resources with a single request.
According to the docs, in case of Channels.list API endpoint, you're able to batch several calls, since, the id property accepts multiple channel IDs in one go:
id (string)
The id parameter specifies a comma-separated list of the YouTube channel ID(s) for the resource(s) that are being retrieved. In a channel resource, the id property specifies the channel's YouTube channel ID.
Note that the API provided me with the following response when asking the Videos.list endpoint to produce info for 64 videos in one go (even only 51 produced the same response):
ERROR 400: Bad Request
{
"error": {
"code": 400,
"message": "The request specifies an invalid filter parameter.",
"errors": [
{
"message": "The request specifies an invalid filter parameter.",
"domain": "youtube.parameter",
"reason": "invalidFilters",
"location": "parameters.",
"locationType": "other"
}
]
}
}
Therefore this API endpoint does not accept more than 50 IDs. It's very much presumable that the others will function the same way.
I'm trying to test on the China sovereign network.
Using these 2 API endpoints for Authentication and Graph API.
https://login.chinacloudapi.cn, https://microsoftgraph.chinacloudapi.cn
Microsoft.Graph.GraphServiceClient graphClient = GraphProvider.GetGraphServiceClient(tenantName, clientId, clientSecret);
graphClient.BaseUrl = "https://microsoftgraph.chinacloudapi.cn/V1.0";
...
var notebooks = await graphClient.Users[userPrincipalName].Onenote.Notebooks.Request().GetAsync();
This does not seem to be working for the China sovereign network. (Works fine for ordinary US endpoint)
Here's the packet dump
Request
GET
/V1.0/users/??????/onenote/notebooks
HTTP/1.1
SdkVersion: Graph-dotnet-1.12.0
Authorization: Bearer
eyJ0eXAiOiJKV1QiLCJub25jZSI6IlFrQ1dPOTFCcWhuMWVub0d3MmRLT3B3aXozS1ZPNnB2TV93Tjl2Vk1va0kiLCJhbGciOiJSUzI1NiIsIng1dCI6InljS3RWOG1aX0pmM25CVmJmZzRmblp1TFFSYyIsImtpZCI6InljS3RWOG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w5sjc7G33GmYh6L6iFm8y_PHg9W14JOfvCaMsvu0QXK9UTc7AWUy09L71ZVw6SGEokfayFfjqh8bkq7jI8CuvOV61tAUgmUJvIijSsl6HwoHVrMJ5D_RLLPdkOD01fN4YDkYCsleEDsgLnqXpzmtOPABzgVuyDfk-saAo4PLl-omN4OTx5-_bJjq5LM_SqTnELihSrYCkaw
Cache-Control: no-store, no-cache
Host: microsoftgraph.chinacloudapi.cn
Response
{ "error": {
"code": "Request_BadRequest",
"message": "Unexpected segment OpenPropertySegment. Expected property/$value.",
"innerError": {
"request-id": "a4cf5da0-715e-4dbd-ad1e-fd4b5e8f2134",
"date": "2020-01-22T19:04:31"
} } }
Am I missing something when calling the API?
Thanks.
Sorry Locke but OneNote is not supported on Microsoft Graph in China for now
If I want to list files in the folder with query parameter $orderBy according to the documentation, I get a response with error 501.
Here is a raw example of request:
GET /v1.0/drives/{id}/items/{id}/children?$select=name,id,folder,lastModifiedDateTime,createdDateTime,size,createdBy,lastModifiedBy,webUrl&$orderby=createdDateTime HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer <token>
The response is:
{
"error": {
"code": "notSupported",
"message": "The request is not supported by the system.",
"innerError": {
"request-id": "c925ae56-8359-4e8f-98b9-92ff0c4dfc8a",
"date": "2018-06-04T10:50:00"
}
}
}
This problem I have only with a specific OneDrive account. If I use the same API call for a different drive and folder, then it works well without any problem.
When I investigated it then it seemed like the API doesn't support parameter $orderBy with date variable inside for this account at all.
Does anyone know why I get this error for a specific account?
I'm trying to create a sharing link for OneDrive item using Microsoft.Graph.CreateLink action:
POST https://graph.microsoft.com/v1.0/me/drive/items/01B642VZR4QM6MX36HGZELNLHCFGY26JJ6/Microsoft.Graph.createLink HTTP/1.1
Authorization: Bearer {access_token}
Content-Type: application/json
{
"type":"edit"
}
and I got the following error:
HTTP/1.1 400 Bad Request
{
"error": {
"code": "BadRequest",
"message": "Version not specified.",
"innerError": {
"request-id": "3ca90464-3910-49e1-92f2-3a9daa822944",
"date": "2016-02-17T15:56:16"
}
}
}
Either method description or metadata does not contain any information about versions needed other than in the API endpoint.
From logs corresponding to request-id:3ca90464-3910-49e1-92f2-3a9daa822944, the request received by the service was "POST https://graph.microsoft.com/". The lack of path segment in the request URL is causing this expected error. Can you please check the request again?