Skip to content
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

PushBullet.deletePush(pushId) #2

Open
KoalaBear84 opened this issue Jul 25, 2014 · 14 comments
Open

PushBullet.deletePush(pushId) #2

KoalaBear84 opened this issue Jul 25, 2014 · 14 comments

Comments

@KoalaBear84
Copy link

When I'm doing this I get an error in the Chrome Console:
NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://api.pushbullet.com/v2/pushes/pushId'.

This is because Google catches the error.

This is a part of the HTML:

400. That’s an error. ##

Your client has issued a malformed or illegal request. That’s all we know.

I don't know if this is because it does not work with HTTP DELETE, or another error.

If you need more information, let me know! Thanks.

@alexschneider
Copy link
Owner

I believe this is an issue with PushBullet's end. Upon testing, I got the following:

XMLHttpRequest cannot load https://api.pushbullet.com/v2/pushes/<pushId>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. 

This likely means that the PushBullet devs don't have the CORS headers properly configured.

@KoalaBear84
Copy link
Author

Yes, that's what I already thought. I also thought, maybe I missed something :P

I will mail them to get it resorted, keep you informed :)

@christopherhesse
Copy link

I think alex already emailed me about this. Can you post the exact request here (all headers, you can edit out the access token) so I can debug the issue?

@KoalaBear84
Copy link
Author

I get a 400 Bad Request from Google Front End

To reproduce, just a HTML page with included pushbullet-js script and the following code:

PushBullet.APIKey = 'YOUR_API_KEY';
var res = PushBullet.push("note", null, null, {title: "<your title here>", body: "<your body here>"});
var pushId = res.iden;
var res = PushBullet.deletePush(pushId);

Here are all the details about the request:

Request URL: https://api.pushbullet.com/v2/pushes/[pushId]
Request Method: DELETE
Status Code: 400 Bad Request

Request Headers
:host: api.pushbullet.com
:method: DELETE
:path: /v2/pushes/[pushId]
:scheme: https
:version: HTTP/1.1
accept: /
accept-encoding: gzip,deflate
accept-language: nl,en-US;q=0.8,en;q=0.6
authorization: Basic [authorizationHash]
content-length: 4
content-type: application/json
origin: http://domain.com
referer: http://domain.com/pushbullet/pushbulletjs.htm
user-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2101.0 Safari/537.36

Request Payload
null

Response Headers
connection: close
content-length: 1419
content-type: text/html; charset=UTF-8
date: Wed, 30 Jul 2014 19:44:58 GMT
server: GFE/2.0
status: 400 Bad Request
version: HTTP/1.1

@christopherhesse
Copy link

I haven't tried to reproduce your error, but from the looks of it you're sending the payload "null". DELETE does not allow a payload and it looks like your request isn't getting to my server because the google front end servers are rejecting it as invalid. Could you try without the payload?

@KoalaBear84
Copy link
Author

Ahh. It looks like I finally get how GitHub works, sort of. The 'strangest' thing is that you need to always fork, even if you are not planning to do anything else than fixing a bug.

Thanks @christopherhesse, that was the key :)

@KoalaBear84
Copy link
Author

Closing as this is already fixed

alexschneider pushed a commit that referenced this issue Oct 25, 2014
Fix #2
Only send a payload if one is absolutely needed. Thanks @KoalaBear84
@KoalaBear84 KoalaBear84 reopened this Oct 27, 2014
@KoalaBear84
Copy link
Author

I've tested this again, because I had to delete some pushes. And it's the same problem again.

I've solved it locally with the following:
if(parameters) {
ajax.send(parameters);
to
if(parameters && parameters != "null") {
ajax.send(parameters);

I thought this was already fixed and finished. :)

@alexschneider
Copy link
Owner

Seriously? That makes no sense. How is it possible for parameters to equal "null"? I know that javascript has weak typing, but it can't be THAT weak.

Do you mind giving me some sample code that replicates this problem?

@KoalaBear84
Copy link
Author

Sorry, little delay :)

This should fail, and give a 500 Internal Server Error or something like that.

// Delete first push
PushBullet.pushHistory(function(err, res) {
    PushBullet.deletePush(res.pushes[0].iden);
});

@KoalaBear84
Copy link
Author

Hi Alex,

Any progress on the test framework? :)

Thanks!

@alexschneider
Copy link
Owner

I know, I've really been slacking on this. I'm working on finals this week, and I hope to really spend some time on all the projects I've been working on (this included), starting this weekend.

@KoalaBear84
Copy link
Author

Now? :P

@KoalaBear84
Copy link
Author

Ever? :)

It's not that I wait on this. But I see it's still opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants