Null returned on successful Unfollow

I in the middle of testing my API wrapper to make sure everything was still working properly. In the documentation it says that a HTTP status should be returned following the operation. When I tested my Unfollow method everything worked, except I’m always getting a null object back even when the operation was successful. The same situation occurs when unblocking a user.

Here’s my method:

public HTTPInfo Unfollow(int user_id)
        RestRequest request = Request("users/{user_id}/follows/channels/{channel_id}", Method.DELETE);
        request.AddUrlSegment("user_id", _id.ToString());
        request.AddUrlSegment("channel_id", user_id.ToString());

        IRestResponse<HTTPInfo> response = client.Execute<HTTPInfo>(request);

        return response.Data;

And here’s my model:

public class HTTPInfo
        public string http_error { get; set; }

        public int http_status { get; set; }

        public string http_message { get; set; }

I’m not sure if this is another quirk with the new API or something on my end. The HTTPInfo model works in every other method as a derived class, and even when I set the return type as just an object, it is still null.

DELETE on kraken endpoints returns 204 No Content when it succeeds. As perhaps obvious, 204 comes with empty response body, which turns into a null variable in your code. You should check the response code instead of attempting to unnecessarily parse the response.

The response content was empty, absolutely nothing was returned.

The response body should be empty, but the response will still have a status code and headers. The status code is what you need to check.

The status code was literally “no content”. Why the hell is the 204 not returned with it.

@3ventic is correct. The body will be empty, but you will get a 204. I just tested this and get a 204 with nothing in the body.


curl -v -H 'Client-ID: redacted' -H 'Accept: application/vnd.twitchtv.v5+json' -H 'Authorization: OAuth redacted' -X DELETE ''


> DELETE /kraken/users/44322889/follows/channels/129454141 HTTP/1.1
> Host:
> User-Agent: curl/7.43.0
> Client-ID: redacted
> Accept: application/vnd.twitchtv.v5+json
> Authorization: OAuth redacted
< HTTP/1.1 204 No Content
< Date: Tue, 03 Jan 2017 15:31:19 GMT

Yeah, I figured out what I was doing wrong shortly after my last reply. Thanks for the reply though :slight_smile:


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.