-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SP REST API returns incorrect date (timezone offset incorrect) #5369
Comments
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible. |
Please add ISPHttpClientOptions to the SPHttpClient.get method. Modify the code as below.
Check the similar thread here: #1684 Dennis Guo |
Thank your for the response but I tried that already with no success. Even double checked if the header was send. I have read the related issues already and searched a lot before posting. I am getting the same results when just using the URL in the browser bar. Guessing it is not a framework issue...more a SharePoint rest problem. The SharePoint is adding a wrong timezone offset after the correct timestamp which is imo just wrong. |
@Dennis-LZ that's not a good solution... you're suggesting to override from an OData v4 request => v3 (when none is specified, SP REST defaults to v3). The recommendation is to use v4, which is set by the @diabhoil Can you check the NETWORK tab on the browser, find the request, and inspect the raw response? Please share the results of the response. Also share a screenshot of the request object (with ALL the request headers). I doubt it's an issue with SPFx's If that's correct, then it would be a question to the REST team... |
The more context details you can provide, the easier it is to help assist on issues. Any code you can provide and/or screenshots of the issue also help. The easier you can make it to reproduce the issue, the easier and quicker it is for someone to help you. Please refer to How to Create Good Issues, specifically How to Create Good Issues: Include context, in our wiki for more details. |
thx for the response @andrewconnell Here is the response (removed all unnessary parts) and sorry for not making screenshots.
Here are the response headers:
And here are the request headers
fyi: Request was send with firefox on win10 german lang, spfx in debug mode. Tested this behaviour on several tenants, in german/english environments (browser/os/sitecollection lang) The creation date was 2020-02-19 09:28 AM german time (GMT+1, UTC+1) |
This isn't a SPFx issue, this is related to the SharePoint REST API. You can see from your raw response, you're getting |
Sorry for the bad code structure and thx for correcting 👍 Yes I have seen the raw response. Tested in Browser, but was not sure if it is maybe a request problem (wrong config or something like that). |
OK... renaming the issue to be more descriptive... need to verify on other tenants first... |
I'm not sure why you are getting data back in the way it's being returned. I expect to see the format like Just tested in 3 of my tenants and everything looks correct, both the date notation in ZULU notation returned & in the accuracy of the value. Not sure if something specific is going on with your tenant... you may need to open a support ticket via your SPO tenant admin... |
@diabhoil Try this... just to be explicit on the response... Copy the request you see in the Network tab as a fetch request: Paste it into the Console and make sure the request headers ask for data as JSON & use the v4 format: Execute... then look at the response in the Network tab... here's what I'm seeing... which is correct & expected: |
@andrewconnell Ok. But my problem is exactly with the /listitemallfields call. All other calls returning the correct date. This is a different tenant and browser now. Just to be 100% sure that its not just our companys tenant. Here is the response. Modified it at 13:11 (german local time) Which would result in |
I have no update sorry. We changed to an other api call (/_api/Web/GetFileByServerRelativePath) to get the correct dates in our project. We had this problem only with the "listitemallfields" call. |
This issue is being closed as part of an issue list cleanup project. Issues with no activity in the past 6 months that aren't tracked by engineering as bugs were closed as part of this inititive. If this is still an issue, please follow the steps outlined to re-open or submit a new issue. |
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues |
Category
Describe the bug
When I try to get the modified date of a file the response contains a date format like this "2020-02-19T09:28:39-08:00". The correct time would be 09:28 in GMT+1 (Berlin Timezone), so the time value is correct, but not the timezone offset. When I try to make a js date with the returned value, I get a totally wrong date "Wed Feb 19 2020 18:28:39 GMT+0100", which would be 9 hours in the future for me. I could just trim the timezone offset at the end or change it to a correct value, but that would be a nasty workaround and maybe just working for my tenant.
Steps to reproduce
Write a spfx webpart and try to get file data with the client:
let fileUrl: string = webUrl + "/_api/Web/GetFileByServerRelativePath(decodedurl=%27" + this.state.documentUrl + "%27)";
let itemUrl: string = fileUrl + "/ListItemAllFields";
context.spHttpClient.get(url, SPHttpClient.configurations.v1).then((response: SPHttpClientResponse) => { return response.json().then((data: any) => {}); })
Expected behavior
At least a date in UTC time like the search api is returning.
Developer environment
SPFX 1.8.2
SharePoint Online
Edge Beta, Chrome
Not sure if its related to spfx at all or if the sharepoint rest api is wrong here. Any help would be nice.
best regards
diabhoil
The text was updated successfully, but these errors were encountered: