سؤال

I am trying to track the download_count of a gitHub release via the gitHub api. I don't need much, I just want to see what it is.

I'm trying to get this information: http://developer.github.com/v3/repos/releases/#response

As you can see from the URL, the return includes a "download_count" key, but unfortunately, my assets array is entirely empty.

By Using This:

NSString * owner = @"...";
NSString * repo = @"...";
NSString * repoId = @"...";

// Get Release Info
NSString * releaseURL = [NSString stringWithFormat:@"https://api.github.com/repos/%@/%@/releases", owner, repo];

// Get Assets List Specifically
NSString * assetsURL = [NSString stringWithFormat:@"https://api.github.com/repos/%@/%@/releases/%@/assets", owner, repo, repoId];

NSURL * gitAssetsURL = [NSURL URLWithString:releaseURL];
NSData * gitAssetsRawData = [NSData dataWithContentsOfURL:gitAssetsURL];
NSString * gitDataString = [[NSString alloc] initWithData :gitAssetsRawData encoding:NSASCIIStringEncoding];
NSLog(@"%@", gitDataString);

Everything outputs fine, but my assets array is always empty. I do have releases, and the assets array is empty on all of my repositories.

هل كانت مفيدة؟

المحلول

Answered by Ivan in Comments, but just to close the question,

Ivan - "Assets are binaries you can upload when creating a release. Try creating a release and look for the "Attach binaries by dropping them here or selecting one." text. We track download counts only for those assets, not for releases themselves (currently)."

نصائح أخرى

@Logan's answer is correct, but I think it should be noted as well that if you're seeing an empty list but did download some files into the release, that you should make sure you used the binaries download. I read his answer and thought that I had done everything correctly.

It turns out there are two sections in the UI, and I missed the binaries one completely. There's a larger (body) section, where you can add files, and right under that, there's a smaller binaries upload section. That was what I missed when I couldn't figure out why my assets were only showing up in the json under "body."

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top