Bing Maps: the Time Zone REST API does not work - timezone

I try to use the Time Zone REST API, and no matter what arguments I use and what coordinate I check, it does not return the expected data, and in all cases I get the result below:
Request:
https://dev.virtualearth.net/REST/v1/TimeZone/point=40.7844503,-73.528732?datetime=2021-04-23T00:00:00Z&includeDstRules=true&key=API_KEY
Response:
{
"authenticationResultCode":"ValidCredentials",
"brandLogoUri":"http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png",
"copyright":"Copyright © 2021 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
"resourceSets":[
{
"estimatedTotal":1,
"resources":[
{
"__type":"RESTTimeZone:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1",
"timeZoneAtLocation":[
]
}
]
}
],
"statusCode":200,
"statusDescription":"OK",
"traceId":"55590586fc5b4183865c58af24845970|DU00000D6E|0.0.0.1|Ref A: 3D98A80E080A45289BEC315D7EE37BDA Ref B: DB3EDGE1522 Ref C: 2021-04-23T14:04:29Z"
}
This is not a Transaction Usage limit issue, I just recently signed up for the service. I tried using other REST API services (such as Elevations API) and it did work.
Please enlighten my eyes and explain to me what is wrong.

It looks like your requesting url is wrong, just remove "point=" from your query would work.
https://dev.virtualearth.net/REST/v1/TimeZone/40.7844503,-73.528732?datetime=2021-04-23T00:00:00Z&includeDstRules=true&key=API_KEY
{
"authenticationResultCode": "ValidCredentials",
"brandLogoUri": "http://dev.virtualearth.net/Branding/logo_powered_by.png",
"copyright": "Copyright © 2021 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
"resourceSets": [
{
"estimatedTotal": 1,
"resources": [
{
"__type": "RESTTimeZone:http://schemas.microsoft.com/search/local/ws/rest/v1",
"timeZone": {
"genericName": "Eastern Standard Time",
"abbreviation": "EST",
"ianaTimeZoneId": "America/New_York",
"windowsTimeZoneId": "Eastern Standard Time",
"utcOffset": "-5:00",
"convertedTime": {
"localTime": "2021-04-22T20:00:00",
"utcOffsetWithDst": "-4:00",
"timeZoneDisplayName": "Eastern Daylight Time",
"timeZoneDisplayAbbr": "EDT"
},
"dstRule": {
"dstStartMonth": "Mar",
"dstStartDateRule": "Sun>=8",
"dstStartTime": "2:00",
"dstAdjust1": "1:00",
"dstEndMonth": "Nov",
"dstEndDateRule": "Sun>=1",
"dstEndTime": "2:00",
"dstAdjust2": "0"
}
}
}
]
}
],
"statusCode": 200,
"statusDescription": "OK",
"traceId": "2fd8f869974046f182ac948253e83de9|HK00000C07|0.0.0.1"
}
You can find more details and examples in
https://learn.microsoft.com/en-us/bingmaps/rest-services/timezone/find-time-zone

Related

How To Convert "created_timestamp" Value To A Valid Date In Python

I'm currently working on a Twitter bot that automatically reply messages, I'm doing this by using tweepy (the official python twitter library)
I need to filter messages based on the created time as I don't want to reply same message twice. Now the problem is that the API endpoint returns created_timestamp as string representation of positive integers.
Below is an example of data returned as per the doc
{
"next_cursor": "AB345dkfC",
"events": [
{ "id": "110", "created_timestamp": "1639919665615", ... },
{ "id": "109", "created_timestamp": "1639865141987", ... },
{ "id": "108", "created_timestamp": "1639827437833", ... },
{ "id": "107", "created_timestamp": "1639825389806", ... },
{ "id": "106", "created_timestamp": "1639825389796", ... },
{ "id": "105", "created_timestamp": "1639825389768", ... },
...
]
}
My question is "How do I convert the created_timestamp to a valid date using python" ?.
You might play with timestamps on this resource
And in your case could use methods like:
timestamp = int('timestamp_string')
datetime.fromtimestamp(timestamp, tz=None)
date.fromtimestamp(timestamp)
From the datetime standard library. But integers after the first line are already well comparable if the task is to distinguish differences between the timestamps.

Twitter API 2.0 - Unable to fetch user.fields

I am using API version 2.0 and unable to fetch the user.fields results. All other parameters seem to be returning results correctly. I'm following this documentation.
url = "https://api.twitter.com/2/tweets/search/all"
query_params = {
"query": "APPL",
"max_results": "10",
"tweet.fields": "created_at,lang,text,author_id",
"user.fields": "name,username,created_at,location",
"expansions": "referenced_tweets.id.author_id",
}
response = requests.request("GET", url, headers=headers, params=query_params).json()
Sample result:
{
'author_id': '1251347502013521925',
'text': 'All conspiracy. But watch for bad news on Apple. Such a vulnerable stocktechnically for the biggest market cap # $2.1T ( Thanks Jay). This is the glue for the bulls. But, they stopped innovating when Steve died, built a fancy office and split the stock. $appl',
'lang': 'en',
'created_at': '2021-06-05T02:33:48.000Z',
'id': '1401004298738311168',
'referenced_tweets': [{
'type': 'retweeted',
'id': '1401004298738311168'
}]
}
As you can see, the following information is not returned: name, username, and location.
Any idea how to retrieve this info?
Your query does actually return the correct data. I tested this myself.
A full example response will be structured like this:
{
"data": [
{
"created_at": "2021-06-05T02:33:48.000Z",
"lang": "en",
"id": "1401004298738311168",
"text": "All conspiracy. But watch for bad news on Apple. Such a vulnerable stocktechnically for the biggest market cap # $2.1T ( Thanks Jay). This is the glue for the bulls. But, they stopped innovating when Steve died, built a fancy office and split the stock. $appl",
"author_id": "1251347502013521925",
"referenced_tweets": [
{
"type": "retweeted",
"id": "1401004298738311168"
}
]
}
],
"includes": {
"users": [
{
"name": "Gary Casper",
"id": "1251347502013521925",
"username": "Hisel1979",
"created_at": "2020-07-11T13:39:58.000Z"
}
]
}
}
The sample result you provided comes from within the data object. However, the expanded object data will be nested in the includes object (in your case name, username, and location). The corresponding user object can be referenced via the author_id field.

Get 'UnableToDeserializePostBody' error after sending a post request to Microsoft Germany endpoint

After sending the following post request to Microsoft Germany endpoint (https://graph.microsoft.de/v1.0), I got 400 UnableToDeserializePostBody, but I received 201 after I sent the same request to Microsoft Graph endpoint (https://graph.microsoft.com/v1.0).
Is there limitation on Germany endpoint?
Request
POST https://graph.microsoft.de/v1.0/users/xxx/events/
{
"attendees":[],
"body":{
"content":"<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=iso-2022-jp\">\r\n<style type=\"text/css\" style=\"display:none\">\r\n<!--\r\np\r\n\t{margin-top:0;\r\n\tmargin-bottom:0}\r\n-->\r\n</style>\r\n</head>\r\n<body dir=\"ltr\">\r\n<div id=\"divtagdefaultwrapper\" dir=\"ltr\" style=\"font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif\">\r\n<p style=\"margin-top:0; margin-bottom:0\"><br>\r\n</p>\r\n</div>\r\n</body>\r\n</html>\r\n",
"contentType":"html"
},
"bodyPreview":"",
"categories":[],
"changeKey":"V3BbxVnFKUiKHwfECS7njQABscz/wA==",
"createdDateTime":"2020-06-22T08:04:02.7260413Z",
"end": {
"dateTime":"2020-06-23T00:30:00.0000000",
"timeZone":"UTC"
},
"hasAttachments":false,
"iCalUId":"",
"id":"AAMkADY5ODA5YjI4LTZlMmEtNDk5My1hNTcxLTFmMDJlMTFlM2ZmYQBGAAAAAADXELVefACVTqbk5n3dmlnfBwBXcFvFWcUpSIofB8QJLueNAAGx1uUKAABXcFvFWcUpSIofB8QJLueNAAGx1vTOAAA=",
"importance":"normal",
"isAllDay":false,
"isCancelled":false,
"isOrganizer":true,
"isReminderOn":true,
"lastModifiedDateTime":"2020-06-22T08:04:03.3837944Z",
"location":{
"address":{
"city":"",
"countryOrRegion":"",
"postalCode":"",
"state":"",
"street":""
},
"coordinates":{},
"locationType":"default",
"uniqueIdType":"unknown"
},
"onlineMeetingUrl":"",
"organizer":{
"emailAddress":{
"address":"a#b",
"name":"test"
}
},
"originalEndTimeZone":"Taipei Standard Time",
"originalStart":null,
"originalStartTimeZone":"Taipei Standard Time",
"recurrence":null,
"reminderMinutesBeforeStart":15,
"responseRequested":true,
"responseStatus":{
"response":"organizer",
"time":"0001-01-01T00:00:00Z"
},
"sensitivity":"normal",
"seriesMasterId":"",
"showAs":"busy",
"start":{
"dateTime":"2020-06-23T00:00:00.0000000",
"timeZone":"UTC"
},
"subject":"1",
"type":"singleInstance",
"webLink":"https://outlook.office.de/owa/?itemid=AAMkADY5ODA5YjI4LTZlMmEtNDk5My1hNTcxLTFmMDJlMTFlM2ZmYQBGAAAAAADXELVefACVTqbk5n3dmlnfBwBXcFvFWcUpSIofB8QJLueNAAGx1uUKAABXcFvFWcUpSIofB8QJLueNAAGx1vTOAAA%3D&exvsurl=1&path=/calendar/item"
}
Response from Germany endpoint
400 Bad Request
{
"error": {
"code": "UnableToDeserializePostBody",
"message": "were unable to deserialize ",
"innerError": {
"date": "2020-08-07T08:44:52",
"request-id": "ce4c6d23-9163-42a1-9839-787596f7533b"
}
}
}
You've probably given up or fixed it by now but I just had this error when setting color. I used an integer but when I changed to string it was ok.
I notice you have "reminderMinutesBeforeStart":15 try it as "reminderMinutesBeforeStart":"15".
I ran into the same issue, and as louisl mentioned it was a problem with using the wrong primitive types in the request object.
I found this library of Typescript Types for the Microsoft Graph Client: https://github.com/microsoftgraph/msgraph-typescript-typings. This library provided the "Event" type, which is what I believe you're using.
Below is a snippet of Typescript that helped me ensure my request object was correct. Notice the Event import and the explicit typing of the eventRequest constant.
import { Event, Attendee } from '#microsoft/microsoft-graph-types'
const eventRequest: Event = {
subject: name,
body: {
contentType: 'html',
content: ...
},
...
}
If you're using VSCode and a Mac you can command + click on the type to look at the definition directly, so you can see what properties are optional, and what types they require. I found Microsoft's type library and in-line comments to be more up-to-date than the official documentation.
It's really useful to explore the type file to get a better idea of how the Microsoft Client works. This principle has been helpful with other libraries as well.

Autopilot and Studio integration

The memory is giving null("") after the task is completed.
can i access the autopilot collected answer again back in studio ?
i just have a task which asks the app date and the im trying to sent the interpreted value to HTTP in studio
{
"collected_data": {
"status": "complete",
"answers": {
"answer": "2020-01-22",
"filled": true,
"attempts": 1,
"validate_attempts": 1,
"confirm_attempts": 0,
"confirmed": false
}
}
}
}
},
but the memory shows empty
is this for Voice?
Check in the Autopilot payload if the variable is directly under the widget i.e. instead of widget.memory.VARIABLE_NAME, if you can find it as widget.VARIABLE_NAME

Youtube API Subscription.ContentDetails.NewItemCount returning zero if querying myself but return different value from Google API Explorer

When using the youtube API to get the list of my subscriptions and all the related details I get a number of information from the snippet and contentDetails part of the response object.
When I call the service from my script the contentDetails.newItemCount always return zero, this should indicate the number of new videos on the channel since last time I've opened the channel. The contentDetails.totalItemCount (total number of videos for the channel) is accurate instead.
In contrast if I run the same query through the google api explorer, the same variable contains the correct information and not zero.
The call I make from my PHP script is exactly the same as the one run on the google api explorer so I can't explain or understand why I'm getting different results. The code I use is roughly the following
$this->_youtube = new Google_Service_YouTube($this->_connector->_googleClient);
$params = array('mine' => true,'maxResults'=>25,'order'=>'alphabetical');
$part = 'snippet,contentDetails';
$response = $this->_youtube->subscriptions->listSubscriptions(
$part,
$params
);
foreach ($response['items'] as $item) {
$this->_mysubscriptions[] = array(
'channelId'=>$item['snippet']['resourceId']['channelId'],
'title'=>$item['snippet']['title'],
'description'=>$item['snippet']['description'],
'thumb_default'=>$item['snippet']['thumbnails']['default']['url'],
'thumb_medium'=>$item['snippet']['thumbnails']['medium']['url'],
'thumb_high'=>$item['snippet']['thumbnails']['high']['url'],
'subscribedOn'=>$this->cleanDate($item['snippet']['publishedAt']),
'totalVideos'=>$item['contentDetails']['totalItemCount'],
'newVideos'=>$item['contentDetails']['newItemCount']);
}
This is how the object returned looks like (just removed few IDs from the response) from the google API explorer, while when I run it through my code I get the same data but the newItemCount is zero.
{
"kind": "youtube#subscription",
"snippet": {
"publishedAt": "2016-09-14T12:48:00.000Z",
"title": "Muselk",
"description": "\"Memes win games\" - Youtube.com/mrmuselk",
"resourceId": {
"kind": "youtube#channel",
"channelId": "UCd534c_ehOvrLVL2v7Nl61w"
},
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/-iWlz7dePNz0/AAAAAAAAAAI/AAAAAAAAAAA/smtPKh-RLTU/s88-c-k-no-mo-rj-c0xffffff/photo.jpg"
},
"medium": {
"url": "https://yt3.ggpht.com/-iWlz7dePNz0/AAAAAAAAAAI/AAAAAAAAAAA/smtPKh-RLTU/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
},
"high": {
"url": "https://yt3.ggpht.com/-iWlz7dePNz0/AAAAAAAAAAI/AAAAAAAAAAA/smtPKh-RLTU/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
}
}
},
"contentDetails": {
"totalItemCount": 792,
"newItemCount": 4,
"activityType": "all"
}
I've looked through the revision history but can't find any reference of modifications made to this specific property of the contentDetails object
There is a bug filed with google on this property but it refers to a different behaviour.
Wondering if this happens to other as well, or if somebody can give some hints on how this works or don't.

Resources