pushbullet-js icon indicating copy to clipboard operation
pushbullet-js copied to clipboard

PushBullet.deletePush(pushId)

Open KoalaBear84 opened this issue 10 years ago • 14 comments

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.

KoalaBear84 avatar Jul 25 '14 08:07 KoalaBear84

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.

alexschneider avatar Jul 28 '14 00:07 alexschneider

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 :)

KoalaBear84 avatar Jul 29 '14 20:07 KoalaBear84

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?

christopherhesse avatar Jul 30 '14 06:07 christopherhesse

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

KoalaBear84 avatar Jul 30 '14 20:07 KoalaBear84

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?

christopherhesse avatar Jul 30 '14 22:07 christopherhesse

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 avatar Jul 30 '14 23:07 KoalaBear84

Closing as this is already fixed

KoalaBear84 avatar Oct 24 '14 11:10 KoalaBear84

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. :)

KoalaBear84 avatar Oct 27 '14 23:10 KoalaBear84

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?

alexschneider avatar Oct 28 '14 04:10 alexschneider

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 avatar Oct 30 '14 08:10 KoalaBear84

Hi Alex,

Any progress on the test framework? :)

Thanks!

KoalaBear84 avatar Dec 09 '14 08:12 KoalaBear84

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.

alexschneider avatar Dec 10 '14 01:12 alexschneider

Now? :P

KoalaBear84 avatar Jan 12 '15 11:01 KoalaBear84

Ever? :)

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

KoalaBear84 avatar Sep 03 '15 09:09 KoalaBear84