Is there a way to change folder and/or message permissions?
I noticed that folders created on root folder of a user, are not visible - is this a bug or a feature?
Thank you.
I sent a POST request with: URL= outlook.office.com/api/v2.0/me/MailFolders/root/childfolders content inside: { "DisplayName": "ExampleName" } The folder was created successfully, and reachable via API's. However it is not visible in the Outlook WebUI nor in the Outlook application. Is this by design? –
The end-point for the root folder is incorrect, there is no need to use the “root” keyword. And this end-point give the error when I try to create a folder.
Here is an sample to create a folder under the root folder for your reference:
POST: https://outlook.office.com/api/v2.0/me/MailFolders
Header:
authorization: bearer {token}
content-type: application/json
BODY:
{"DisplayName":"FolderName"}
And we will the 201 status code and response like figure below:
Related
Please bare with me for a question for which it's nearly impossible to create a reproducible example.
I have an API setup with FastAPI using Docker, Serverless and deployed on AWS API Gateway. All routes discussed are protected with an api-key that is passed into the header (x-api-key).
I'm trying to accomplish a simple redirect from one route to another using fastapi.responses.RedirectResponse. The redirect works perfectly fine locally (though, this is without api-key), and both routes work perfectly fine when deployed on AWS and connected to directly, but something is blocking the redirect from route one (abc/item) to route two (xyz/item) when I deploy to AWS. I'm not sure what could be the issue, because the logs in CloudWatch aren't giving me much to work with.
To illustrate my issue let's say we have route abc/item that looks like this:
#router.get("/abc/item")
async def get_item(item_id: int, request: Request, db: Session = Depends(get_db)):
if False:
redirect_url = f"/xyz/item?item_id={item_id}"
logging.info(f"Redirecting to {redirect_url}")
return RedirectResponse(redirect_url, headers=request.headers)
else:
execution = db.execute(text(items_query))
return convert_to_json(execution)
So, we check if some value is True/False and if it's False we redirect from abc/item to xyz/item using RedirectResponse(). We pass the redirect_url, which is just the xyz/item route including query parameters and we pass request.headers (as suggested here and here), because I figured we need to pass along the x-api-key to the new route. In the second route we again try a query in a different table (other_items) and return some value.
I have also tried passing status_code=status.HTTP_303_SEE_OTHER and status_code=status.HTTP_307_TEMPORARY_REDIRECT to RedirectResponse() as suggested by some tangentially related questions I found on StackOverflow and the FastAPI discussions, but that didn't help either.
#router.get("/xyz/item")
async def get_item(item_id: int, db: Session = Depends(get_db)):
execution = db.execute(text(other_items_query))
return convert_to_json(execution)
Like I said, when deployed I can successfully connect directly to both abc/item and get a return value if True and I can also connect to xyz/item directly and get a correct value from that, but when I pass a value to abc/item that is False (and thus it should redirect) I get {"message": "Forbidden"}.
In case it can be of any help, I try debugging this using a "curl" tool, and the headers I get returned give the following info:
Content-Type: application/json
Content-Length: 23
Connection: keep-alive
Date: Wed, 27 Jul 2022 08:43:06 GMT
x-amzn-RequestId: XXXXXXXXXXXXXXXXXXXX
x-amzn-ErrorType: ForbiddenException
x-amz-apigw-id: XXXXXXXXXXXXXXXX
X-Cache: Error from cloudfront
Via: 1.1 XXXXXXXXXXXXXXXXXXXXXXXXX.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: XXXXX
X-Amz-Cf-Id: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
So, this is hinting at a CloudFront error. Unfortunately I don't see anything slightly hinting at this API when I look into my CloudFront dashboard on AWS, there literally is nothing there (I do have permissions to view the contents though...)
The API logs in CloudWatch look like this:
2022-07-27T03:43:06.495-05:00 Redirecting to /xyz/item?item_id=1234...
2022-07-27T03:43:06.495-05:00 [INFO] 2022-07-27T08:43:06.495Z Redirecting to /xyz/item?item_id=1234...
2022-07-27T03:43:06.496-05:00 2022-07-27 08:43:06,496 INFO sqlalchemy.engine.Engine ROLLBACK
2022-07-27T03:43:06.496-05:00 [INFO] 2022-07-27T08:43:06.496Z ROLLBACK
2022-07-27T03:43:06.499-05:00 END RequestId: 6f449762-6a60189e4314
2022-07-27T03:43:06.499-05:00 REPORT RequestId: 6f449762-6a60189e4314 Duration: 85.62 ms Billed Duration: 86 ms Memory Size: 256 MB Max Memory Used: 204 MB
I have been wondering if my issue could be related to something I need to add to somewhere in my serverless.yml, perhaps in the functions: part. That currently looks like this for these two routes:
events:
- http:
path: abc/item
method: get
cors: true
private: true
request:
parameters:
querystrings:
item_id: true
- http:
path: xyz/item
method: get
cors: true
private: true
request:
parameters:
querystrings:
item_id: true
Finally, it's probably good to note that I have added custom middleware to FastAPI to handle the two different database connections I need for connecting to other_items and items tables, though I'm not sure how relevant this is, considering this functions fine when redirecting locally. For this I implemented the solution found here. This custom middleware is the reason for the redirect in the first place (we change connection URI based on route with that middleware), so I figured it's good to share this bit of info as well.
Thanks!
As noted here and here, it is mpossible to redirect to a page with custom headers set. A redirection in the HTTP protocol doesn't support adding any headers to the target location. It is basically just a header in itself and only allows for a URL (a redirect response though could also include body content, if needed—see this answer). When you add the authorization header to the RedirectResponse, you only send that header back to the client.
A suggested here, you could use the set-cookie HTTP response header:
The Set-Cookie HTTP response header is used to send a cookie from the
server to the user agent (client), so that the user agent can send it back to
the server later.
In FastAPI—documentation can be found here and here—this can be done as follows:
from fastapi import Request
from fastapi.responses import RedirectResponse
#app.get("/abc/item")
def get_item(request: Request):
redirect_url = request.url_for('your_endpoints_function_name') #e.g., 'get_item'
response = RedirectResponse(redirect_url)
response.set_cookie(key="fakesession", value="fake-cookie-session-value", httponly=True)
return response
Inside the other endpoint, where you are redirecting the user to, you can extract that cookie to authenticate the user. The cookie can be found in request.cookies—which should return, for example, {'fakesession': 'fake-cookie-session-value-MANUAL'}—and you retrieve it using request.cookies.get('fakesession').
On a different note, request.url_for() function accepts only path parameters, not query parameters (such as item_id in your /abc/item and /xyz/item endpoints). Thus, you can either create the URL in the way you already do, or use the CustomURLProcessor suggested here, here and here, which allows you to pass both path and query parameters.
If the redirection takes place from one domain to another (e.g., from abc.com to xyz.com), please have a look at this answer.
I have a file that i know exists in one drive , TestFile.xlxs.It sits in the folder
Folder1/SubFolder2/SubFolder 2a/. I am trying t get the fileId as follows, so i can move the file to another folder in OneDrive
https://graph.microsoft.com/v1.0/me/drive/root:/Folder1/SubFolder2/SubFolder 2a/TestFile.xlsx
but i get the error
"code": "BadRequest",
"message": "Empty Payload. JSON content expected.",
Any ideas how i can get the id of the file ?
Looks like you did POST request instead of GET.
GET https://graph.microsoft.com/v1.0/me/drive/root:/Folder1/SubFolder2/SubFolder 2a/TestFile.xlsx
POST request will probably work if you add empty json into the request body.
{}
1.This is the behavior I am observing when I use Update DriveItem graph API to update my file name.https://learn.microsoft.com/en-us/graph/api/driveitem-update?view=graph-rest-1.0&tabs=http.
2.If the file is open in my office desktop document it throws locked exception. If i close the file renaming works fine.
3.I tested same in sharepoint their UI ,I am able to rename the file.But through graph API it throws locked exception if file is open.
Is this error expected ?. How can I get around this
https://learn.microsoft.com/en-us/graph/api/driveitem-update?view=graph-rest-1.0&tabs=http.
PATCH https://graph.microsoft.com/v1.0/drives/b!qnfox2pppU-AeWEPhWpRhNiB9gIq_ANJq5NFCiklU2Y5F3fDc7fsaQvB/items/014UHAXWYO5LX2RTA6YZE37E4XTG45PTTW
SdkVersion : graph-java/v1.6.0
Authorization : Bearer
{"name":"V-blah (1) (113_0_4_26).docx"}
423 : Locked
Strict-Transport-Security : max-age=31536000
Cache-Control : private
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"West US","Slice":"SliceC","Ring":"5","ScaleUnit":"000","RoleInstance":"AGSFE_IN_57"}}
client-request-id : 33f16bde-55d1-XXXX
request-id : XXXXXXX
Content-Length : 251
Date : Sat, 02 May 2020 04:05:23 GMT
Content-Type : application/json
{
"error": {
"code": "resourceLocked",
"message": "The resource you are attempting to access is locked",
"innerError": {
"request-id": "d1bfa1f2-cXXXXX",
"date": "2020-05-02T04:05:23"
}
}
}
Ensure that the document library does not have "check-in required" enabled.
Assuming check-in is not required, I received the same HTTP 423 "resourceLocked" response for both scenarios: file opened in the browser (SharePoint Online UI) and file opened in desktop client. I believe this is working by design that you can't update a file's name when it is currently opened by another user or yourself in another instance.
Please see this reference about files locked for editing.
Try adding the HeaderOption that bypasses the shared lock, to the request.
new Microsoft.Graph.HeaderOption("Prefer", "bypass-shared-lock")
If you are using the graphServiceClient, add it to a List and pass it directly in your Request.
i am working on a zendframework 2 project and want to receive post variables from an external source.
the source where the values will come from is a payment site (i.e world pay and paypal). i.e the return values of a payment confirming that payment has been made.
on the external site, i simply gave the URL of the web page that i want the information to be returned to:
http://example-site.com/payments/payment-made
then in action function on the controller page i did the following;
public function paymentMadeAction()
{
$contents = file_get_contents('php://input'); // read request contents
$data = explode('&', $contents);
if ($contents)
{
foreach($data as &$entry) {
$entry = explode('=', $entry);
$entry[1] = urldecode($entry[1]);
}
unset($entry);
}
print_r($data);
}
nothing happens though. i mean, i tested it but the values are not being received. when i went to the external source to check if my site received the information it confirmed that the information had been successfully sent
is there a special procedure that needs to be followed when receiving information from an external source in zend framework 2
would really appreciate any guidance or advise.
update:
below is a sample of the post variable that should be returned to the site; its a simply http object
POST /fail?installation=XXXXXX&msgType=authResult HTTP/1.0
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Host: www.worldpay.com
Content-Length: 973
User-Agent: WJHRO/1.0 (worldPay Java HTTP Request Object)
region=new+format+region&authAmountString=%26%23163%3B10.00&_SP.charEnc=UTF8&desc=&tel=&address1=new+format+address1)
you are doing it in the absolute WRONG way, the correct way to get post(or query or route ) variables in ZF2 action :
$this->params()->fromPost();
or
$this->request->getPost()->toArray();
How do I create a new folder (called "test") in my personal locker using Desire2Learn's REST API? I've tried this request, but it doesn't work:
POST /d2l/api/le/1.0/locker/mylocker/?x_a={appID}&x_c={appSig}&x_b={myUserID}&x_d={myUserSig}&x_t={time) HTTP/1.1
Host: myHost.com
Accept: */*
Content-type: application/json
{ "test" }
The server sends me back a 200 status, but also tells me "an unexpected error occurred". I've tested all the auth parameters with other routes, and they seem to work. What am I doing wrong?
This is a slightly unusual call;
The JSON data has to be just like this:
"test"
Not:
{ "test" }
There is an example in the docs of this but it is recent.