Calling https://graph.microsoft.com/v1.0/users/<ID Calendar>/calendar/calendarView? doesn't return appointments, and there is appointments - api

The call to Graph API is not working properly since yesterday :
https://graph.microsoft.com/v1.0/users/<my calendar ID>/calendar/calendarView?startDateTime=2019-10-04T19:10:24.0000000&endDateTime=2019-11-03T19:10:24.0000000&top=100
Is returning 0 events - appointments, and there are appointments to list on
That call was working ok until yesterday, every 8 minutes, 24x7 since last month :
// List events.
string fini = string.Format("{0}-{1}-{2}T{3}:{4}:{5}.0000000",
UpDateTime.Year.ToString("0000"),
UpDateTime.Month.ToString("00"),
UpDateTime.Day.ToString("00"),
UpDateTime.Hour.ToString("00"),
UpDateTime.Minute.ToString("00"),
UpDateTime.Second.ToString("00")
);
string ffin = string.Format("{0}-{1}-{2}T{3}:{4}:{5}.0000000", //
EndTime.Year.ToString("0000"),
EndTime.Month.ToString("00"),
EndTime.Day.ToString("00"),
EndTime.Hour.ToString("00"),
EndTime.Minute.ToString("00"),
EndTime.Second.ToString("00")
);
String _requestURI = _GraphURLEvents.Replace("events", "calendarView") + string.Format("?startDateTime={0}&endDateTime={1}&top=100", fini, ffin);
_requestURI = String.Format(_requestURI, _userId);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, _requestURI);
//Authentication token
request.Headers.Add("Prefer", "outlook.timezone=\"Romance Standard Time\"");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", System.Web.HttpUtility.UrlEncode(access_token));
HttpClient client = new HttpClient();
var response = await client.SendAsync(request)
var returnURL = await
response.Content.ReadAsStringAsync();
Get kind CALL returns:
{StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Transfer-Encoding: chunked
request-id: <r>
client-request-id: <t>
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"West Europe","Slice":"SliceC","Ring":"5","ScaleUnit":"003","RoleInstance":"AGSFE_IN_52","ADSiteName":"WEU"}}
Preference-Applied: outlook.timezone="Romance Standard Time"
OData-Version: 4.0
Duration: 66.8258
Strict-Transport-Security: max-age=31536000
Cache-Control: private
Date: Fri, 04 Oct 2019 17:11:31 GMT
Content-Type: application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8
}}
Content: {System.Net.Http.StreamContent}
Headers: {Transfer-Encoding: chunked
request-id: <x>
client-request-id: <y>
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"West Europe","Slice":"SliceC","Ring":"5","ScaleUnit":"003","RoleInstance":"AGSFE_IN_52","ADSiteName":"WEU"}}
Preference-Applied: outlook.timezone="Romance Standard Time"
OData-Version: 4.0
Duration: 66.8258
Strict-Transport-Security: max-age=31536000
Cache-Control: private
Date: Fri, 04 Oct 2019 17:11:31 GMT
}
IsSuccessStatusCode: true
ReasonPhrase: "OK"
RequestMessage: {Method: GET, RequestUri: 'https://graph.microsoft.com/v1.0/users/<mycalendar>/calendar/calendarView?startDateTime=2019-10-04T19:10:24.0000000&endDateTime=2019-11-03T19:10:24.0000000&top=100', Version: 1.1, Content: <null>, Headers:
{
Prefer: outlook.timezone="Romance Standard Time"
Authorization: Bearer <my authorization bearer>
}}
StatusCode: OK
Version: {1.1}
That call must return something like :
https://learn.microsoft.com/en-us/graph/api/user-list-calendarview?view=graph-rest-1.0&tabs=http
HTTP/1.1 200 OK
Content-type: application/json
Content-length: 354
{
"value": [
{
"originalStartTimeZone": "originalStartTimeZone-value",
"originalEndTimeZone": "originalEndTimeZone-value",
"responseStatus": {
"response": "",
"time": "datetime-value"
},
"iCalUId": "iCalUId-value",
"reminderMinutesBeforeStart": 99,
"isReminderOn": true
}
]
}
... and since yesterday the result is :
{\"#odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#users('<calendarId>')/calendar/calendarView\",\"value\":[]}

Based on my test the url should be:
1. To get the calendar of a specific user
https://graph.microsoft.com/v1.0/users/<user_id>/calendar/calendarView?startDateTime=2019-10-06T16:00:00Z&endDateTime=2019-10-10T16:00:00Z&top=100
or
https://graph.microsoft.com/v1.0/users/<user_id>/calendars/<calendar_id>/calendarView?startDateTime=2019-10-06T16:00:00Z&endDateTime=2019-10-10T16:00:00Z&top=100
2. To get the calendar of me
https://graph.microsoft.com/v1.0/me/calendar/calendarView?startDateTime=2019-10-06T16:00:00Z&endDateTime=2019-10-10T16:00:00Z&top=100
or
https://graph.microsoft.com/v1.0/me/calendars/<calendar_id>/calendarView?startDateTime=2019-10-06T16:00:00Z&endDateTime=2019-10-10T16:00:00Z&top=100
I can get successful responses from the above urls.
By the way, please check if you have set the correct time period. The timestamp should be UTC formatted.

Related

Box api call returning 403 forbidden error in Vue but the same URL working in postman

I have a developer token for box and the box app all set up. when I use Postman I get the data that I am looking for returned. I have looked at the headers that Postman is sending and have provided the same in my code.
axios({
async: true,
crossDomain: true,
url: 'https://api.box.com/2.0/files/<File ID>/',
method: 'GET',
headers: {
'Postman-Token': '<Postman Token>',
'cache-control': 'no-cache',
Authorization: 'Bearer <Developer Token>',
Accept: '*/*',
},
}).then((res) => {
console.log(res);
}).catch(console.error);
This returns a 403 in the browser.
This is the Response Headers from Postman:
Date:"Wed, 03 Apr 2019 06:04:45 GMT"
Content-Type:"application/json"
Transfer-Encoding:"chunked"
Connection:"keep-alive"
Strict-Transport-Security:"max-age=31536000"
Cache-Control:"no-cache, no-store"
ETag:""0""
Content-Encoding:"gzip"
Vary:"Accept-Encoding"
BOX-REQUEST-ID:"<BOX-REQUEST-ID>"
Age:"0"
Response Headers from bowser
Access-Control-Allow-Origin: *
Age: 0
BOX-REQUEST-ID: <BOX-REQUEST-ID>
Cache-Control: no-cache, no-store
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json
Date: Wed, 03 Apr 2019 06:36:01 GMT
Strict-Transport-Security: max-age=31536000
Transfer-Encoding: chunked
Vary: Origin,Accept-Encoding
Error in browser dev tools
GET https://api.box.com/2.0/files/<File ID>/ 403 (Forbidden)
Error: Request failed with status code 403
at createError (createError.js?2d83:16)
at settle (settle.js?467f:18)
at XMLHttpRequest.handleLoad (xhr.js?b50d:77)

Google BigQuery Insert API returning 200 but not inserting data

Referencing https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata/insertAll
Google BigQuery API is returning 200 however the data is not being inserted in the table;
Request
POST https://www.googleapis.com/bigquery/v2/projects/***/datasets/***/tables/visits/insertAll?fields=insertErrors%2Ckind&key={YOUR_API_KEY}
{
"rows": [
{
"json": {
"hostId": "Value A",
"statusCode": "Value B"
}
},
{
"insertId": "inser-id-yo",
"json": {
"hostId": "Value A",
"statusCode": "Value B"
}
}
]
}
Response
Response: 200
cache-control: no-cache, no-store, max-age=0, must-revalidate
content-encoding: gzip
content-length: 69
content-type: application/json; charset=UTF-8
date: Fri, 16 Dec 2016 12:00:16 GMT
etag: "wWvNncJfeAdSHVaIWRpICxBS7AM/vyGp6PvFo4RvsFtPoIWeCReyIC8"
expires: Mon, 01 Jan 1990 00:00:00 GMT
pragma: no-cache
server: GSE
vary: Origin, X-Origin
{
"kind": "bigquery#tableDataInsertAllResponse"
}
My BigQuery table however is empty and no data is being inserted.
I know there a number of SDKs however I need to be able to do this via Curl as I am working in a language where Google have not developed and SDK.
Anyone else who had this problem, its because BigQuery can have up to a two hour delay.
It took me a while to find the answer.
Once i got rid of the line setInsertId(String.valueOf(System.currentTimeMillis()))
please see: Data streaming insertAll api usage not equal to actually inserted rows

How to correctly handle multiple Set-Cookie headers in Hyper?

I'm using Hyper to send HTTP requests, but when multiple cookies are included in the response, Hyper will combine them to one which then fails the parsing procedure.
For example, here's a simple PHP script
<?php
setcookie("hello", "world");
setcookie("foo", "bar");
Response using curl:
$ curl -sLD - http://local.example.com/test.php
HTTP/1.1 200 OK
Date: Sat, 24 Dec 2016 09:24:04 GMT
Server: Apache/2.4.25 (Unix) PHP/7.0.14
X-Powered-By: PHP/7.0.14
Set-Cookie: hello=world
Set-Cookie: foo=bar
Content-Length: 0
Content-Type: text/html; charset=UTF-8
However for the following Rust code:
let client = Client::new();
let response = client.get("http://local.example.com/test.php")
.send()
.unwrap();
println!("{:?}", response);
for header in response.headers.iter() {
println!("{}: {}", header.name(), header.value_string());
}
...the output will be:
Response { status: Ok, headers: Headers { Date: Sat, 24 Dec 2016 09:31:54 GMT, Server: Apache/2.4.25 (Unix) PHP/7.0.14, X-Powered-By: PHP/7.0.14, Set-Cookie: hello=worldfoo=bar, Content-Length: 0, Content-Type: text/html; charset=UTF-8, }, version: Http11, url: "http://local.example.com/test.php", status_raw: RawStatus(200, "OK"), message: Http11Message { is_proxied: false, method: None, stream: Wrapper { obj: Some(Reading(SizedReader(remaining=0))) } } }
Date: Sat, 24 Dec 2016 09:31:54 GMT
Server: Apache/2.4.25 (Unix) PHP/7.0.14
X-Powered-By: PHP/7.0.14
Set-Cookie: hello=worldfoo=bar
Content-Length: 0
Content-Type: text/html; charset=UTF-8
This seems to be really weird to me. I used Wireshark to capture the response and there're two Set-Cookie headers in it. I also checked the Hyper documentation but got no clue...
I noticed Hyper internally uses a VecMap<HeaderName, Item> to store the headers. So they concatenate the them to one? Then how should I divide them into individual cookies afterwards?
I think that Hyper prefers to keep the cookies together in order to make it easier do some extra stuff with them, like checking a cryptographic signature with CookieJar (cf. this implementation outline).
Another reason might be to keep the API simple. Headers in Hyper are indexed by type and you can only get a single instance of that type with Headers::get.
In Hyper, you'd usually access a header by using a corresponding type. In this case the type is SetCookie. For example:
if let Some (&SetCookie (ref cookies)) = response.headers.get() {
for cookie in cookies.iter() {
println! ("Got a cookie. Name: {}. Value: {}.", cookie.name, cookie.value);
}
}
Accessing the raw header value of Set-Cookie makes less sense, because then you'll have to reimplement a proper parsing of quotes and cookie attributes (cf. RFC 6265, 4.1).
P.S. Note that in Hyper 10 the cookie is no longer parsed, because the crate that was used for the parsing triggers the openssl dependency hell.

backbone.js fetch is not updating the model

I have read other posts here and it looks like most of the time this boils down to fetch being async. I don't think that is my problem because 1. I test the results in the success callback of fetch and 2. I can console.log(model.toJSON()) in the js console later and it still is not updated
Notes: I am getting a good json response from the API and I can get the data by putting 'parse' in my model declaration like so
parse: function(data){
alert(data.screenname);
}
Here is my code, why is the model not being updated with the fetch call
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="vendor/components/underscore/underscore-min.js"></script>
<script src="vendor/components/backbone/backbone-min.js"></script>
</head>
<body>
Hello
<script>
$.ajaxSetup({
beforeSend: function(xhr){
xhr.setRequestHeader("Authorization", "Basic " + window.btoa("username" + ":" + "password"));
}
});
var User=Backbone.Model.extend({
parse: function(data){
alert(data.screenname);
},
urlRoot: 'http://api.myapi.com/user'
});
var user=new User({id:'1'});
user.fetch({
success: function(collection, response, options){
console.log(response);
console.log(user.toJSON());
}
});
</script>
</body>
</html>
When I log response, it show a good json coming back, but user.toJSON just shows the id as 1.
I can use parse in the model declaration to manually assign each value in the model from the response, but that seems like a dumb way to do it. I was under the impression that fetch() was supposed to populate the model with the result from the server.
**UPDATED**
Here is the response I get back from the server
{"id":1,"email":"test#email.com","password":"pass","screenname":"myname","id_zipcode":1,"id_city":1,"date_created":"2014-12-25 12:12:12"}
Here are the response headers from my api
HTTP/1.1 200 OK
Date: Tue, 04 Feb 2014 18:31:41 GMT
Server: Apache/2.2.24 (Unix) DAV/2 PHP/5.5.6 mod_ssl/2.2.24 OpenSSL/0.9.8y
X-Powered-By: PHP/5.5.6
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Authorization, Origin, X-Requested-With, Content-Type, Accept
Set-Cookie: PHPSESSID=pj1hm0c2ubgaerht3i5losga4; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 139
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: application/json; charset=utf-8
You have overridden your parse() method to effectively do nothing. It should return all the attributes to set on your model; you have not returned anything, hence, nothing was being set on the model.
It should look like this.
var User=Backbone.Model.extend({
parse: function(data){
alert(data.screenname);
return data; //all attributes in data will be set on the model
},
urlRoot: 'http://api.myapi.com/user'
});

Google cloud storage objective c sample

I got the Google API for Objective C for using Cloud Storage Module from below path.
Google API Objective-C Client
Unluckily the api didn't provide any Sample Code for Cloud Storage so I tried to do it myself but I couldn't be successful. Below is what I am doing
I enabled my billing for Cloud Storage from Google API Console
I made a bucket with name "ahs_test"
I made a Client ID for installed applications
I got successful with Outh2.0 with the library available at upper SVN Path. After doing this I wrote below code and get below error message
Note that After reading Google Cloud Storage I am sort of sure that I have to send the "x-goog-project-id" in my request header but I am wondering that this API's code doesn't do anything like that. ( I might be doing some mistake so leaving this for getting any sort of help.. Thanks in Advance...)
// Code....
GTLServiceStorage *service = self.storageService
GTLQueryStorage *query = [GTLQueryStorage queryForBucketsGetWithBucket:#"ahs_test"];
_fileListTicket = [service executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLStorageBuckets *bucketList,
NSError *error) {
}];
// Error Message I get (Detailed from loger)
storage.buckets.get
2012-12-30 07:11:30 +0000
Request: POST https://www.googleapis.com/rpc?prettyPrint=false
Request headers:
Accept: application/json-rpc
Authorization: Bearer _snip_
Cache-Control: no-cache
Content-Type: application/json-rpc; charset=utf-8
User-Agent: com.example.DriveSample/1.0 google-api-objc-client/2.0 MacOSX/10.8 (gzip)
Request body: (128 bytes)
{
"jsonrpc" : "2.0",
"method" : "storage.buckets.get",
"id" : "gtl_3",
"params" : {
"bucket" : "ahs_test",
"max-results" : 150
},
"apiVersion" : "v1beta1"
}
Response: status 200
Response headers:
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Encoding: gzip
Content-Length: 132
Content-Type: application/json; charset=UTF-8
Date: Sun, 30 Dec 2012 07:10:44 GMT
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Pragma: no-cache
Server: GSE
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Response body: (168 bytes)
{
"error" : {
"message" : "Access Not Configured",
"data" : [
{
"reason" : "accessNotConfigured",
"message" : "Access Not Configured",
"domain" : "usageLimits"
}
],
"code" : 403
},
"id" : "gtl_3"
}
The Google API library uses the Cloud Storage JSON API, which isn't enabled by default. Please check to see if it is enabled in the Google APIs console.