DELETE request timing out [Fixed :]

I’m trying to write a library in C# to communicate with the Spark Cloud. So far so good with everything except for deleting old access tokens. I can list token fine, but when I use the DELETE method with the same ID/password combo my request times out.

Here’s the code I’m using:

WebClient wc = new WebClient();
wc.Headers[HttpRequestHeader.Authorization] = "Basic " + encodeCreds(id, pw);
string retval = wc.UploadString(temp_url, "DELETE", "");

and previously:

WebRequest wr = WebRequest.Create(temp_url);
wr.Headers.Add("Authorization", "Basic " + encodeCreds(id, pw));
wr.Method = "DELETE";
HttpWebResponse res = (HttpWebResponse)wr.GetResponse();

I’m a webdev by day but I’ve not had much experience with the DELETE method, so any help would be greatly appreciated.

I have no clue in C# but this might help?

http://docs.spark.io/api/#authentication-deleting-an-access-token

1 Like

Yeah, I’ve been reading that for the past day hoping I’d overlooked something.

1 Like

I don’t know anything about C# either, but I think you should play around with preauthenticate and see if that helps:

http://msdn.microsoft.com/en-us/library/system.web.services.protocols.webclientprotocol.preauthenticate.aspx

2 Likes

Hi @andreburto,

Looks like you hit a bug in the API, I’ll look into it!

Thanks,
David

1 Like

Thanks for the reply. I’ll keep an eye on the updates before I use the code again.

1 Like

Hi @andreburto,

Thanks for drawing this to my attention again! I found and fixed the bug, and it’ll get included in our next rollout. :slight_smile:

Thanks,
David

2 Likes

Awesome! Thanks so much.

I can honestly say I’m looking forward to deleting some keys in the near future.

2 Likes

@Dave, thanks for the fix! I tried my code out the other night and I could delete the keys. It worked beautifully. :slight_smile: You rock!

2 Likes

This is happening to me as of tonights testing. I'm getting this back.

<html>
    <head>
        <title>502 Bad Gateway</title>
    </head>
    <body bgcolor="white">
        <center>
            <h1>502 Bad Gateway</h1>
        </center>
        <hr>
            <center>nginx/1.6.0</center>
        </body>
    </html>
    <!-- a padding to disable MSIE and Chrome friendly error page -->
    <!-- a padding to disable MSIE and Chrome friendly error page -->
    <!-- a padding to disable MSIE and Chrome friendly error page -->
    <!-- a padding to disable MSIE and Chrome friendly error page -->
    <!-- a padding to disable MSIE and Chrome friendly error page -->
    <!-- a padding to disable MSIE and Chrome friendly error page -->

Postman is also returning a few of these inbetween as well.

Could not get any response
This seems to be like an error connecting to https://api.spark.io/v1/access_tokens/4f4b1d00854000c8e40d3c4ea4e2caa5340a7a30. The response status was 0.
Check out the W3C XMLHttpRequest Level 2 spec for more details about when this happens.

Bump. Would be nice to get an update here.

Is that to me or the official Spark people?

I can look at my code if you mean me, but the last time I used it on my desktop client I could generate a new token with ID/password.

@andreburto Sorry for the confusion. This would be for the official spark folks, because I am still unable to delete keys and getting server timeouts as in my original reply to this thread. So I guess the right person would be someone like @Dave ?

Heya @OrangeOctober,

Sorry about the delay, hmm. aha, found it.

OK, so our normal production api diverged because of the IFTTT integration we built over the last few months. We’ve fixed this bug, but it’s not in the normal stable production api yet. Now that we’ve released IFTTT (last week), I can begin merging these branches back together, and should have that rolled out early next week.

tl;dr; it’s fixed but not pushed, will push next week. :slight_smile:

Thanks,
David

Hi @Dave
I went today to test again, and was able to delete 1 access token. When trying to delete the 2nd most recent (or any other) access token, it times out again

Could not get any response
This seems to be like an error connecting to https://api.spark.io/v1/access_tokens. The response status was 0.
Check out the W3C XMLHttpRequest Level 2 spec for more details about when this happens.
1 Like

I am overjoyed to report that this is finally working for me. :joy:

1 Like