Google-api-dotnet-client: Google.Apis.Requests.RequestError : Track names in request path and request body must match

Created on 12 Mar 2020  路  8Comments  路  Source: googleapis/google-api-dotnet-client

Hello,

I have been using this nuget package for quite a while and since few days, I am not able to upload any APK.
My code didn't change, just the error appears after I updated the nuget package.

I got this exception :

Google.Apis.Requests.RequestError
Track names in request path and request body must match. [400]
Errors [
Message[Track names in request path and request body must match.] Location[ - ] Reason[badRequest] Domain[global]]

Here is my code :

public IUploadProgress UploadAPK(AppEdit edit, string packageName, string versionName, Stream file, string releaseNotes, string track)
{
           // Upload APK
            var uploadedApk = this.Service.Edits.Apks.Upload(
              packageName,
              edit.Id,
              file,
              "application/octet-stream");

            // Upload Callback
            uploadedApk.ResponseReceived += (apk) =>
            {
                if (apk == null)
                {
                    return;
                }

                // Get VersionCode
                List<long?> apkVersionCodes = new List<long?> { apk.VersionCode };

                // Create Realease Note
                LocalizedText note = new LocalizedText();
                note.Language = LANG_FR;
                note.Text = releaseNotes;

                var updatedTrack = this.Service.Edits.Tracks.Update(
                    new Track()
                    {
                        Releases = new List<TrackRelease>
                        {
                            new TrackRelease
                            {
                                Name = versionName,
                                VersionCodes = apkVersionCodes,
                                Status = "completed",
                                ReleaseNotes = new List<LocalizedText>() { note }
                            }
                        }
                    },
                    packageName,
                    edit.Id,
                    track);

                updatedTrack.Execute();

                var appEdit = this.Service.Edits.Commit(packageName, edit.Id).Execute();
            };

            var result = uploadedApk.Upload();
}

The error is showed when updatedTrack.Execute(); is called.

I have no idea where I can fix this.

Is it a bug or is anyone know how to fix this ?

Thanks for your help.

question

Most helpful comment

After looking for a solution, I tried something and it worked!

I just added to the _Track_ object (the "body") the string value of _TrackValue_ and it worked :

TrackValue = track,

                var updatedTrack = this.Service.Edits.Tracks.Update(
                    new Track()
                    {
                        TrackValue = track,
                        Releases = new List<TrackRelease>
                        {                            
                            new TrackRelease
                            {
                                Name = versionName,
                                VersionCodes = apkVersionCodes,
                                Status = "completed",
                                ReleaseNotes = new List<LocalizedText>() { note }
                            }
                        }
                    },
                    packageName,
                    edit.Id,
                    track);

It could be nice to find an update notes when they update the API.

Anyway, the problem is solved, thanks all for your help.

All 8 comments

Since I've started to look for the problem, it all seems that the issue is coming from Google API.

I really don't think that the problem is coming from the package nuget anymore

Is there any way to see if they updated the API recently (like release notes) ?

I'm afraid that varies on a per-API basis. I can't immediately tell for sure which exact API this is about - is it the Google Play Developer API? If so, I'm afraid I can't find any release notes :( Perhaps contact Play support?

Yes, it's the Google Play Developer API.

That's too bad we cannot check if they update the API...

I'll try with the support, thanks

I have the same exact problem since yesterday, something has changed in their API

After looking for a solution, I tried something and it worked!

I just added to the _Track_ object (the "body") the string value of _TrackValue_ and it worked :

TrackValue = track,

                var updatedTrack = this.Service.Edits.Tracks.Update(
                    new Track()
                    {
                        TrackValue = track,
                        Releases = new List<TrackRelease>
                        {                            
                            new TrackRelease
                            {
                                Name = versionName,
                                VersionCodes = apkVersionCodes,
                                Status = "completed",
                                ReleaseNotes = new List<LocalizedText>() { note }
                            }
                        }
                    },
                    packageName,
                    edit.Id,
                    track);

It could be nice to find an update notes when they update the API.

Anyway, the problem is solved, thanks all for your help.

Thanks @GrecoRom1 that works for me as well, though I had to place the addition under new Track() instead of new List<TrackRelease> (typo I assume? Or would that be a pasto?)

Thanks @GrecoRom1 , adding the track name seems to be a new mandate on play store upload api.

Thanks @GrecoRom1 that works for me as well, though I had to place the addition under new Track() instead of new List<TrackRelease> (typo I assume? Or would that be a pasto?)

You're right, I updated my answer

Was this page helpful?
0 / 5 - 0 ratings