I am using Microsoft Graph API version 1.9.0 and I was able to get my photo by this code
try
{
var originalPhoto = await GraphClient.Me.Photo.Content.Request().GetAsync();
return originalPhoto;
}
catch (Exception ex)
{
return null;
}
But from today it throws exception:
Code: ErrorApiQuarantined
Message: Request has been quarantined by condition.
This is the response header
request-id: 4189c59d-9c1f-4686-945d-2cb9756491ed
client-request-id: 4189c59d-9c1f-4686-945d-2cb9756491ed
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"East Asia","Slice":"SliceC","Ring":"4","ScaleUnit":"000","RoleInstance":"AGSFE_IN_1"}}
Strict-Transport-Security: max-age=31536000
Cache-Control: private
Date: Mon, 21 Oct 2019 03:20:09 GMT
Please let me know what is happening with my Graph Client.
This is not client side issue. Requests on the servers are blocked for specific api/tenant/user due to excessive usage which can degrade service. I suggest you file case with support to check with product group what condition led to this and why rule is created. Usually these rules are created temporarily.
Related
We are using the Sharepoint Rest API to index contents.
Due to a customer's security requirement, we can only use API permissions as granted in the Sharepoint Admin Center in combination with an app-only principal with a secret.
We registered an application in the Azure AD Admin Center and granted it permissions as described here.
We then wrote a piece of Java Code that adapts the requests described here to retrieve a JWT:
List<NameValuePair> params = new ArrayList<>(10);
params.add(new BasicNameValuePair("grant_type", "client_credentials"));
params.add(new BasicNameValuePair("client_id", clientId + "#" + directoryId));
params.add(new BasicNameValuePair("client_secret", clientSecret));
params.add(new BasicNameValuePair("resource", "00000003-0000-0ff1-ce00-000000000000/" + targetHost + "#" + directoryId));
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
HttpPost post = new HttpPost("https://accounts.accesscontrol.windows.net/" + directoryId + "/tokens/OAuth/2");
post.setEntity(new UrlEncodedFormEntity(params, Consts.UTF_8));
String result;
try (CloseableHttpResponse response = httpClient.execute(post)) {
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK)
throw new SharepointClient.HttpStatusException(response.getStatusLine().getStatusCode());
result = Strings.fromUtf8(IO.readAll(response.getEntity().getContent()));
}
accessToken = new JsonData(result).get("access_token");
}
We then use the token as a bearer token in the authorization header for all requests to the API.
This worked fine for a couple of months until about a week ago. Since then, we're only receiving 403 responses.
HttpResponseProxy{HTTP/1.1 403 Forbidden [Cache-Control: private, max-age=0, Transfer-Encoding: chunked, Content-Type: application/json;odata=verbose;charset=utf-8, Expires: Wed, 30 Sep 2020 09:58:49 GMT, Last-Modified: Thu, 15 Oct 2020 09:58:49 GMT, P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI", X-SharePointHealthScore: 2, X-MSDAVEXT_Error: 917656; Zugriff+verweigert.+Zum+%c3%96ffnen+von+Dateien+an+diesem+Speicherort+m%c3%bcssen+Sie+zun%c3%a4chst+zur+Website+wechseln+und+die+Option+zur+automatischen+Anmeldung+aktivieren., DATASERVICEVERSION: 3.0, X-AspNet-Version: 4.0.30319, SPRequestGuid: f7dd839f-10d1-2000-73fa-40c47dd29bbb, request-id: f7dd839f-10d1-2000-73fa-40c47dd29bbb, MS-CV: n4Pd99EQACBz+kDEfdKbuw.0, Strict-Transport-Security: max-age=31536000, X-FRAME-OPTIONS: SAMEORIGIN, Content-Security-Policy: frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.stream.azure-test.net *.microsoftstream.com;, X-Powered-By: ASP.NET, MicrosoftSharePointTeamServices: 16.0.0.20530, X-Content-Type-Options: nosniff, X-MS-InvokeApp: 1; RequireReadOnly, X-MSEdge-Ref: Ref A: 330CB0BA15E647CC8B732FCC45D4F950 Ref B: AM3EDGE0620 Ref C: 2020-10-15T09:58:49Z, Date: Thu, 15 Oct 2020 09:58:49 GMT] ResponseEntityProxy{[Content-Type: application/json;odata=verbose;charset=utf-8,Chunked: true]}}
The error message is in german (I don't know why, the whole system is set to english). It sais: "Access denied. To open files in this location, you have to first go to the website and activate the option for automatic login."
Does anyone know what might have changed? Do we need to change something in the requests?
We already checked:
The secret is not expired
Authentication via certificate and Azure AD Admin Center permissions is still working (same API requests, just the token retrieval is done with msal4j)
Sending the token request and the API requests via Postman leads to the same results
The reason for the error is not that you lack permissions. According to the error message Access denied. To open files in this location, you have to first go to the website and activate the option for automatic login.
Do you need:
1.Authenticate to Office 365.
2.Add your SharePoint Online sites to trusted sites.
3.Check the status of the WebClient service.
see: Troubleshoot mapped network drives that connect to SharePoint Online.
I'm trying to upload multiple files to a client's SharePoint using separate calls to the following endpoint
https://graph.microsoft.com:443/v1.0/drives/{drive-id}/root:/{itemId}:/microsoft.graph.createUploadSession.
An average of fifty files upload successfully, but eventually I receive the following error.
Error = {
Code: generalException
Message: An unspecified error has occurred.
Inner Exception: {
Additional Data: {[
{[request-id, 34068a5e-41ac-4009-814a-f085f7e03443]},
{[date, {1/23/2020 3:59:27 PM}]}
]}
}
}
Below is the received response header
{
request-id: 34068a5e-41ac-4009-814a-f085f7e03443
client-request-id: 34068a5e-41ac-4009-814a-f085f7e03443
x-ms-ags-diagnostic: {
"ServerInfo":{
"DataCenter":"South Central US",
"Slice":"SliceC",
"Ring":"4",
"ScaleUnit":"002",
"RoleInstance":"AGSFE_IN_5"
}
}
Strict-Transport-Security: max-age=31536000
Cache-Control: private
Date: Thu, 23 Jan 2020 15:59:27 GMT
}
I don't think our application is being throttled since we're not receiving a 429 response. I also don't believe it is a file size issue as the files are under 4MBs
In the end, the issue was related to a space at the end of a folder name within our path.
We were constructing paths based on user named entities and were failing to trim them before uploading to Sharepoint. Oddly, we were allowed to upload one file to the Sharepoint which seemed to trim the elements of the path accordingly, but the second file uploaded would always throw the above error.
RequestResult strReq = OAuthUtility.Put(
"https://content.dropboxapi.com/1/files_put/auto/",
new HttpParameterCollection {
{"access_token",MYAccessToken},
{"path",Path.Combine(this.CurrentPath, Path.GetFileName(#"C:\test\jj.kk\Downloads\1990480.jpg")).Replace("\\","/")},
{"overwrite","true"},
{"autorename","true"}
}
);
I am using above code for uploading file on Dropbox but giving following error:
The remote server returned an error: (400) Bad Request.
RequestResult : { "error": "Content-Type (application/x-www-form-urlencoded) may not be one of (\'application/x-www-form-urlencoded\', \'multipart/form-data\')" }
Httpheader :
{Transfer-Encoding: chunked
Connection: keep-alive
X-Dropbox-Request-Id: 4029d2ae041cf1f25d8f58d06d158b83
X-Robots-Tag: noindex, nofollow, noimageindex
Content-Type: application/json
Date: Fri, 07 Oct 2016 15:24:17 GMT
Server: nginx
}
Is there any other way of uploading files on Dropbox in ASP.NET?
The error message you're getting is indicating that the issue with your API request is that the Content-Type has an unexpected value. That is, you (via the library you're using, presumably) are sending application/x-www-form-urlencoded. That isn't an allowed format for the Dropbox API /1/files_put endpoint, which expects the raw file data in the body of the request.
To answer your actual question though, there is another way to upload to Dropbox in ASP.NET. You can use Dropbox API v2, instead of Dropbox API v1 as you have here. (And in fact you should, since Dropbox API v1 is deprecated.)
To do so, we highly recommend using the official SDK:
https://www.dropbox.com/developers/documentation/dotnet
Alternatively, you can use the HTTP endpoints directly, e.g.,:
https://www.dropbox.com/developers/documentation/http/documentation#files-upload
When I call the captions.download endpoint with an ID that we retrieve from the captions.list endpoint, it always returns a 403. For example:
https://www.youtube.com/watch?v=1HRwpwOj4aA
I call captions.list with:
GET https://www.googleapis.com/youtube/v3/captions?part=id&videoId=1HRwpwOj4aA&key={YOUR_API_KEY}
This is response:
cache-control: private, max-age=0, must-revalidate, no-transform
content-encoding: gzip
content-length: 236
content-type: application/json; charset=UTF-8
date: Sat, 23 May 2015 17:55:57 GMT
etag: "dhbhlDw5j8dK10GxeV_UG6RSReM/Rztb3ln4Zb6O07vb7_KSZi2y1NM"
expires: Sat, 23 May 2015 17:55:57 GMT
server: GSE
vary: Origin, X-Origin
{
"kind": "youtube#captionListResponse",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/Rztb3ln4Zb6O07vb7_KSZi2y1NM\"",
"items": [
{
"kind": "youtube#caption",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/pwH-4wtyQJz0U3l57fA8uKm4e1I\"",
"id": "kHlUsiuNS4TjB25loauZNXGrjK91I1tEdNyOpTRNA78="
}
]
}
When I use the above id to call captions.download:
GET https://www.googleapis.com/youtube/v3/captions/kHlUsiuNS4TjB25loauZNXGrjK91I1tEdNyOpTRNA78%3D?key={YOUR_API_KEY}
This is response:
403 Forbidden
cache-control: private, max-age=0
content-encoding: gzip
content-length: 29
content-type: text/html; charset=UTF-8
date: Sat, 23 May 2015 17:59:05 GMT
expires: Sat, 23 May 2015 17:59:05 GMT
server: GSE
vary: Origin, X-Origin
Forbidden
Any ideas what could be happening here?
From the YouTube API docs:
403 Forbidden: The permissions associated with the request are not
sufficient to download the caption track. The request might not be
properly authorized, or the video order might not have enabled
third-party contributions for this caption.
Instead caption download API that sometimes returns 403 (if video not have enabled third-party contributions for this caption) you can use youtube.com/api/timedtext
what you wrote above about "only works for videos your google account owns" is not my experience. I just successfully ran captions.download on a video (about dog training) which I definitely do not own - do not even have a dog. However, I have tested the exact same code on the video mentioned here on stackoverflow and get a 403 error.
So no it doesn't always return a 403 sometimes it returns a 200! Try it with the dog video mentioned above:
python captions.py --videoid="jBN2_YuTclU" --action="download" --captionid='8S2GjnNfitU5HHoLyTeLxq_W1dP29YRFC8E8vFBUtws='
with the code you probably already have here.
It will need your client_secrets.json downloaded from the Google credentials page somewhere and a missing file youtube-v3-api-captions.json which you can get from here. The code launches a browser where you log in for OAuth2 authorisation.
Still, there must be a reason why it works for some videos and not others. #Abhishek might have it above. The wrong comment has been upvoted there. Nothing in the output of captions.list for a video that allows captions downloads and a video that does not is obviously different which would explains why one works and the other does not. If anyone can supply which {'key':'value'} pair in the youtube api controls this would be helpful.
Status 403 Forbidden means that nobody has the right to access that URL. You shouldn't receive that message if you have the wrong API key, for example; that should give Status 401 Unauthorised. I'd check the URL carefully.
I have an ID of a Youtube video and like to add a Thumbnail with the google-api-client (Ruby). My request looks like this
result = client.execute(:api_method => youtube.thumbnails.set, :parameters => { :videoId => my_video_id, :media_body => file })
What result.data returns is this
<Google::APIClient::Schema::Youtube::V3::ThumbnailSetResponse:0x86435518 DATA:{"error"=>{"code"=>500, "message"=>nil}}>
I can't figure out, what the problem is here. I tried to use a path to a file on my local machine as well as a URL. Even an empty String as the file location or leaving out the media_body leads to the 500 error.
Does anyone of you know, what's going on here and why I don't get a clear error response?
Edit: It seems to be not the fault of the google-api-client, because testing the same request in the Google APIs Explorer produces the same result:
Response
500 Internal Server Error
cache-control: private, max-age=0
content-encoding: gzip
content-length: 66
content-type: application/json; charset=UTF-8
date: Wed, 19 Feb 2014 14:24:23 GMT
expires: Wed, 19 Feb 2014 14:24:23 GMT
server: GSE
{
"error": {
"code": 500,
"message": null
}
}
Not all channels are enabled for custom thumbnails; I suspect that if you're getting an error, it might be because you're attempting to set a custom thumbnail for a video in a channel that isn't enabled. There's more info at https://support.google.com/youtube/answer/72431?hl=en
Could you follow the steps in that help article and see whether you have an option in the web UI to set a custom thumbnail? If you don't, then your channel isn't enabled.
Getting back a HTTP 500 response is obviously unhelpful, though, and makes it difficult to confirm that that's what's going on. We can follow up with the engineering team about that to get a helpful error returned once we confirm whether your channel is enabled or not.