My resource observer closure was called twice with the same error, is this a bug? - siesta-swift

I have a Siesta resource to which I use the closure version of AddObserver. Right now, the endpoint that that resource uses always returns a 404. Most of the time, the observing closure only gets called once with the error. However, I have a log file where I see the exact same error (same timestamp and everything) being called twice. The error looks like this:
RequestError(userMessage: "Not found", httpStatusCode: Optional(404), entity: Optional(Siesta.Entity<Any>(content: "<h2>404 - Page Not Found</h2><p>The page could not be found.</p>", charset: Optional("utf-8"), headersNormalized: ["access-control-allow-headers": "Content-Type, Authorization", "set-cookie": "connect.sid=s%3APGOwgU4q3fhlxhag0E9Sc1zN_R9jTjH0.IAp%2BfAIfqxqP%2Bt5zZ1f0t1terpWgoRHpQhF%2BfB0gxyw; Path=/; HttpOnly", "etag": "W/\"40-ca3ea152\"", "via": "1.1 vegur", "content-length": "64", "content-type": "text/html; charset=utf-8", "date": "Sun, 17 Sep 2017 01:05:43 GMT", "access-control-allow-methods": "DELETE,GET,PATCH,POST,PUT", "connection": "keep-alive", "x-powered-by": "Express", "vary": "Accept-Encoding", "server": "Cowboy", "access-control-allow-origin": "*"], timestamp: 527303143.37699503)), cause: nil, timestamp: 527303143.37563998)
Are there cases where I should receive this error twice? Is it not a guarantee that the observer is only called once in this situation? Is it a bug??? Is that bug in Siesta, the networking library, or my code?

Related

Getting different results from same request with MS Graph API

I am writing an app using microsoft graph api. I want to run the command.
https://graph.microsoft.com/v1.0/drives
Unfortunately when I do this with the app I get different results from the app and graph explorer.
https://developer.microsoft.com/en-us/graph/graph-explorer
{
"access-control-allow-origin": "https://graphtryit.azurewebsites.net",
"access-control-expose-headers": "Content-Encoding,Server,Access-Control-Allow-Origin,Access-Control-Expose-Headers,Strict-Transport-Security,request-id,client-request-id,x-ms-ags-diagnostic,x-ms-resource-unit,OData-Version,X-FE-DATA",
"cache-control": "public, must-revalidate, max-age=300",
"client-request-id": "$$ID OMITED$$",
"content-type": "application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8",
"odata-version": "4.0",
"request-id": "$$ID OMITED$$",
"server": "Microsoft-IIS/10.0",
"strict-transport-security": "max-age=31536000",
"x-ms-ags-diagnostic": "$$OMITED$$"
}
This is the header info for the App
{
'Cache-Control': 'no-store, no-cache',
'Transfer-Encoding': 'chunked',
'Content-Type':'application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8',
'Content-Encoding': 'gzip',
'Vary': 'Accept-Encoding',
'Strict-Transport-Security': 'max-age=31536000',
'request-id': '$$ID OMITED$$',
'client-request-id': '$$ID OMITED$$',
'x-ms-ags-diagnostic': '{"ServerInfo":{"DataCenter":"$$OMITED DIFFERENT SERVER$$"}}',
'OData-Version': '4.0',
'Date': 'Tue, 01 Nov 2022 17:52:48 GMT'
}
Why do you think the two would yield different results? The app has its permissions in place. It's an azure active directory app. The azure request yields one drive. While the graph explorer tool yields all the drives available. Lol new discovery some instances of the graph explorer show what the api does and the other doesn't
New development:
https://learn.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-1.0&tabs=http#code-try-1
Shows all drives when you input /drives
but https://developer.microsoft.com/en-us/graph/graph-explorer?request=drives&method=GET&version=v1.0&GraphUrl=https://graph.microsoft.com doesn't show all when you enter /drives
{
"cache-control": "no-store, no-cache",
"client-request-id": "$$ID OMITTED$$",
"content-type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8",
"request-id": "$$ID OMITTED$$"
}
Okay I figured it out. The learn site outputs all fake data from
"access-control-allow-origin": "https://graphtryit.azurewebsites.net"
The learn site should not be used to compare to your applications output when debugging your application. Except to get a general idea of what normal output looks like.

Possible bug when adding a newly created video to a playlist

As of recently, a script has been reporting failures when trying to add a newly created youtube video to a playlist.
The flow is pretty simple:
URL being requested: POST https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&alt=json&part=status%2Csnippet
Video id 'ABC123' was successfully uploaded.
Adding ABC123 to playlist MyPlaylistId
URL being requested: POST https://www.googleapis.com/youtube/v3/playlistItems?alt=json&part=snippet
Payload:
{"snippet": {"resourceId": {"kind": "youtube#video", "videoId": "ABC123"}, "playlistId": "MyPlaylistId"}}
Response:
{'status': '404', 'content-length': '226', 'x-xss-protection': '0', 'x-content-type-options': 'nosniff', 'transfer-encoding': 'chunked', 'vary': 'Origin, X-Origin, Referer', 'server': 'scaffolding on HTTPServer2', '-content-encoding': 'gzip', 'cache-control': 'private', 'date': 'Thu, 17 Sep 2020 12:13:36 GMT', 'x-frame-options': 'SAMEORIGIN', 'alt-svc': 'h3-Q050=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"', 'content-type': 'application/json; charset=UTF-8'}
Response content:
{
"error": {
"code": 404,
"message": "Video not found.",
"errors": [
{
"message": "Video not found.",
"domain": "youtube.playlistItem",
"reason": "videoNotFound"
}
]
}
}
Now, the funny part is that the video is actually successfully added to the playlist. I have tested it several times and I get the same result.
Can anyone confirm this bug?
It seems indeed a bug, but, as far as I know, the site for post about bugs with the YouTube APIs is: Issue Tracker1.
The following link allows you create an entry on Issue Tracker.
It is worth check first if entries exists with the similar issue you're facing and if you find related entries there, please "star" that issue to draw attention to it and track updates, if you'd like.
1 Issue Tracker is shown (alongside Stack Overflow) at the end of the page of YouTube Data API website.

InternalServerError Object reference not set to an instance of an object when creating an open extension using Microsoft Graph Api

I received "InternalServerError", "Object reference not set to an instance of an object." when creating an open extension for a group.
I tried to create an open extension for a group:
POST https://graph.microsoft.com/v1.0/groups/[group id]/extensions
{
"#odata.type" : "microsoft.graph.openTypeExtension",
"extensionName": "com.test.1235",
"watermarks": "abc",
"id": "com.test.1235"
}
Headers:
Authorization: bearer [access token]
Content-Type: application/json
This is the response I received:
500 Internal Server Error
{
"error": {
"code": "InternalServerError",
"message": "Object reference not set to an instance of an object.",
"innerError": {
"request-id": "56d5fd05-cf69-4a91-85b6-dcfce7894e13",
"date": "2019-06-17T10:52:44"
}
}
}
Headers:
request-id: 56d5fd05-cf69-4a91-85b6-dcfce7894e13
client-request-id: 56d5fd05-cf69-4a91-85b6-dcfce7894e13
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"Southeast Asia","Slice":"SliceC","Ring":"2","ScaleUnit":"000","RoleInstance":"AGSFE_IN_5","ADSiteName":"SEA"}}
Date: Mon, 17 Jun 2019 10:52:44 GMT
This did not just happen for groups. Creating an extension for a user also returned the same error. Given the "Object reference not set to an instance of an object." message I assume there is a bug somewhere in the backend. Otherwise please let me know how to fix the request to avoid this error.
We're rolling back to the previous Graph deployment while we investigate and root cause the issue. The issue should be mitigated shortly and then API requests to create open extensions should be working again. Thank you for reporting this!

GeoJSON Python Eve Example

I am trying to make a GeoJSON query work as per the Eve documentation (v0.6.1-dev): http://python-eve.org/features.html
However, the query in postman returns an error:
Postman GET: http://localhost:5000/people?where={"location": {"$near": {"$geometry": {"type":"Point", "coordinates": [10.0, 20.0]}, "$maxDistance": 1000}}}
Error:
500 Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
The 'people' collection contains the location as show below:
Postman GET: http://localhost:5000/people
"_items": [
{
"_updated": "Wed, 30 Sep 2015 10:26:51 GMT",
"firstname": "John",
"lastname": "Doe",
"born": "Thu, 27 Aug 1970 14:37:13 GMT",
"role": [
"author"
],
**"location": {
"type": "Point",
"coordinates": [
100,
0
]
},**
"_links": {
"self": {
"href": "people/560bb8eb6adf7d0e70f26cd0",
"title": "person"
}
},
Any idea why this does not work ?
Try to switch on debug mode (set DEBUG = True in settings) and see what the actual error is. It is very likely that there is no geo index for the field (Eve does not automatically create indexes for you).
UPDATE: Starting with v0.6, you can also ask Eve to maintain the index for you, see the mongo_indexes keyword in the docs

404 error when posting new forum post in Desire2Learn 10.0

I'm working with the D2L API,and am having difficulty with some POST requests.
Doing a version check (POST) using the JSON object:
[{ "ProductCode": "lp", "Version": "1.0" }]
returns correctly, providing me a valid JSON object in response, that being said I'm confident that my code to issue the call is working correctly.
When I issue a POST to create a post in a forum, however, I get a 404 in response. The JSON object I'm sending for this call is:
[
{
"ParentPostId": null,
"Subject": "API Posted",
"Message": {
"Text": "This message has been posted by the API",
"HTML": "This message has been posted by the API"
},
"IsAnonymous": false
}
]
And the URL submitted to is /d2l/api/le/{ver}/{orgId}/discussions/forums/{forumId}/topics/{topicId}/posts/
I've verified that ver/orgId/forumId/topicId are all valid using a GET of a post in the same forum and topic. I've also tried quoting the values for ParentPostId and IsAnonymous both separately and in unison.
Try removing the square brackets from the JSON.
An example of a successful request and response follows:
REQUEST
POST https://valence.desire2learn.com/d2l/api/le/1.0/7664/discussions/forums/203/topics/508/posts/?x_b=TwULqrltMXvTE8utuLCN5O&x_a=L2Hd9WvDTcyiyu5n2AEgpg&x_d=nF61tBeuzd0EPTW7nm8iGc4MB7NeJZaNM2VlzHp0bwU&x_c=I3i_k2aANTIf2X6aFsiOdvlElSR_avvOYnA2ibcWabA&x_t=1343335429 HTTP/1.1
Accept-Encoding: gzip,deflate
Accept: application/json
Content-Type: application/json
{ "ParentPostId": null, "Subject": "API Posted", "Message": { "Content": "This message has been posted by the API", "Type": "HTML" }, "IsAnonymous": false }
RESPONSE
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Pragma: no-cache
Content-Length: 369
Content-Type: application/json; charset=UTF-8
Expires: -1
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Date: Thu, 26 Jul 2012 20:43:58 GMT
{"ForumId":203,"PostId":574,"TopicId":508,"PostingUserId":3667,"ThreadId":205,"ParentPostId":null,"Message":{"Text":"","Html":"This message has been posted by the API"},"Subject":"API Posted","DatePosted":"2012-07-26T20:43:58.920Z","IsAnonymous":false,"RequiresApproval":false,"IsDeleted":false,"LastEditDate":null,"LastEditedBy":null,"CanRate":false,"ReplyPostIds":[]}
Looking at the documentation for that route at http://docs.valence.desire2learn.com/res/discuss.html#post--d2l-api-le-(D2LVERSION-version)-(D2LID-orgUnitId)-discussions-forums-(D2LID-forumId)-topics-(D2LID-topicId)-posts-, it looks like the required data structure uses a RichTextInput not a RichText for Message.
Try changing your Message field to:
{
"Content": "This message has been posted by the API",
"Type": "Text"
}

Resources