cake-contrib / Cake.HockeyApp

This Addin for the Cake allows you to upload your package to HockeyApp.
http://cakebuild.net/dsl/hockeyapp
MIT License
4 stars 13 forks source link

Duplicate Hockeyapp entries using `master`, or 422 error on `develop` #14

Closed dracan closed 7 years ago

dracan commented 7 years ago

Hi,

It's likely that this is just me using it incorrectly, but I'm struggling to get it to work. Thought I'd check here in case these are known issues. I can always try and dig a little deeper otherwise :)

I've tried with both the latest version on nuget (master branch), and have also compiled and tried the latest version from the develop branch - but am having different issues with both ...

The version on nuget does work, however it seems to create two separate entries in Hockeyapp. Looking at what my computer is sending using Fiddler, it seems to be doing a POST to create the app, then doing a further PUT with the application in it. I notice that the later version doesn't seem to do a PUT.

When I try using the latest version, it fails saying (422) Unprocessable Entity. Using Fiddler again, the error in the POST response body says ...

{"errors":{"bundle_version":["can't be blank"]}}

I am specifying both the Version and the ShortVersion.

Below is my cake task ...

Task("HockeyAppDeploy")
    .IsDependentOn("Build")
    .Does(() => {
        UploadToHockeyApp(signedApkPath, new HockeyAppUploadSettings 
        {
            AppId = hockeyAppAppId,
            ApiToken = hockeyAppApiToken,
            Version = newVersionCode.ToString(),
            ShortVersion = newVersionNumber,
            Notes = "Uploaded from Cake",
            Notify = NotifyOption.AllTesters,
            Mandatory = MandatoryOption.Mandatory,
            Status = DownloadStatus.Allowed,
            Private = false,
            ReleaseType = ReleaseType.Beta
        });
    });

Below is the request captured from Fidder ...

POST https://rink.hockeyapp.net/api/2/apps/*******************/app_versions/new HTTP/1.1
Content-Type: multipart/form-data; boundary=----CakeUpload32423423423423*****
X-HockeyAppToken: ***********************
Host: rink.hockeyapp.net
Content-Length: 377
Expect: 100-continue
Connection: Keep-Alive

------CakeUpload54beab43PcfafP4732Pb06aPf12e********
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=bundle_version

1090
------CakeUpload54beab4*****************************
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=bundle_short_version

1.0.9.0
------CakeUpload54be**********************--

I notice that it doesn't seem to be sending most of the properties I set in the the Cake task (although the one from nuget does).

Are these known issues at the moment?

Thanks for your help, and as I say - I can always dig deeper if they're not known issues.

Thanks, Dan

msjogren commented 7 years ago

I hit the same problem today (422 Unprocessable Entity). The core issue is that the bundle_version and bundle_short_version field names must have quotes around them.

MultiPartFormDataContentExtensions.AddIfNotEmpty adds quotes around the field name, but that extension method isn't used by HockeyAppApiClient.CreateNewVersionAsync.

If you post the same request but with _Content-Disposition: form-data; name="bundleversion" and _Content-Disposition: form-data; name="bundle_shortversion" (using curl for example), the request succeeds.

gep13 commented 7 years ago

@msjogren If you are able to, I would happily accept a PR for this. Thank you!

jonlipsky commented 7 years ago

@gep13 I submitted a PR that addresses this since I was running into the issue as well.

msjogren commented 7 years ago

@jonlipsky Beat me to it. Great, thanks!