Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaceship::TunesClient::ITunesConnectError: invalid request body #6711

Closed
2 tasks done
summera opened this issue Oct 25, 2016 · 16 comments
Closed
2 tasks done

Spaceship::TunesClient::ITunesConnectError: invalid request body #6711

summera opened this issue Oct 25, 2016 · 16 comments

Comments

@summera
Copy link
Contributor

summera commented Oct 25, 2016

New Issue Checklist

Issue Description

Receiving Spaceship::TunesClient::ITunesConnectError: invalid request body when calling Spaceship::Tunes.select_team. The request to set the team id on line 88 is returning HTTP 400. Here is the response body:

{
  "data"=>nil,
  "messages"=>{"warn"=>nil, "error"=>["invalid request body"], "info"=>nil}, 
  "statusCode"=>"ERROR"
}

I did some digging with switching teams in ITC and it looks like Spaceship needs the dsId param in the ra/v1/session/webSession. Once I added this param to the request, I received a 200 and everything worked as expected.

response = request(:post) do |req|
  req.url "ra/v1/session/webSession"
  req.body = { contentProviderId: team_id, dsId: 'mydsid' }.to_json
  req.headers['Content-Type'] = 'application/json'
end

Note: by the time i got this posted there was a duplicate: #6710 . sorry about that

@ldiqual
Copy link
Contributor

ldiqual commented Oct 25, 2016

@summera I'm sure the fastlane team will react promptly, but in the meantime is there a workaround besides patching the gem?

@summera
Copy link
Contributor Author

summera commented Oct 25, 2016

I'm not quite sure what the dsId is yet because I can't even load ITC right now haha. Maybe its the user's ID? So I'm not sure if Spaceship provides a way to obtain this ID already. As far as I can tell this needs to be in the request for it to work now. So immediate fix would be patching.

@chakming
Copy link

chakming commented Oct 25, 2016

@summera ITC seems updated, have a new login page layout now
image

@summera
Copy link
Contributor Author

summera commented Oct 25, 2016

@chakming yea ITC was telling me it was down for a few and now login page looks a little different. I think everything else seems to be the same and error still exists though.

dsId is different for each user. If you go to your Personal Details for your account it's the id at the end of that URL... https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/users_roles/#{dsid}

@chakming
Copy link

@summera found one interesting thing: if I use another dsId which is not refer to my user account, it still works

@summera
Copy link
Contributor Author

summera commented Oct 25, 2016

Ha. You're right. Just putting a random ID does work. This worked for me:

      response = request(:post) do |req|
        req.url "ra/v1/session/webSession"
        req.body = { contentProviderId: team_id, dsId: '123' }.to_json
        req.headers['Content-Type'] = 'application/json'
      end

@ChrisVolentine
Copy link

@summera I added a random dsId to my request body like you have, and it started working again for me as well

@summera
Copy link
Contributor Author

summera commented Oct 25, 2016

I found that the actual dsId can be obtained from the user detail request in TunesClient#user_detail_data inside the sessionToken json object. It's just not parsed from the response in the current implementation.

@luskin
Copy link

luskin commented Oct 25, 2016

^ worked for me as well!

@KrauseFx
Copy link
Member

Hey everyone, thanks for the reports, I can reproduce the issue, I'm working on a fix 🚀

@summera
Copy link
Contributor Author

summera commented Oct 25, 2016

@KrauseFx just came up with this:

summera@7f8adc3

I can open PR if you'd like.

KrauseFx added a commit that referenced this issue Oct 25, 2016
Fixes #6711
Fixes #6710

Thanks @summera for providing a solution for the problem
@KrauseFx
Copy link
Member

Awesome, thank you @summera, I pushed this via #6716. Preparing a new release in a minute

@KrauseFx
Copy link
Member

Hey, thanks for your patience everyone, we were able to push new releases for spaceship, pilot and deliver, please update to the latest release using [sudo] gem update deliver or [sudo] gem update pilot. If you're using bundler use bundle update instead 👍

Special thanks to @summera for providing a super fast fix, and @milch for reviewing all the required version bumps and dependency updates 🚀

Please let us know if that solves the issue for you.

@santoshshetty2612
Copy link

updated to latest version of deliver and fastlane. Invalid request body error is resolved now.
But getting the following error:

ruby-2.3.0/gems/deliver-1.14.4/lib/deliver/setup.rb:63:in block in generate_metadata_files': [!] undefined method<<' for nil:NilClass (NoMethodError)
from .rvm/gems/ruby-2.3.0/gems/deliver-1.14.4/lib/deliver/setup.rb:57:in `each'

@KrauseFx
Copy link
Member

@santoshshetty2612 That's a separate issue, I'll provide a fix in a minute 👍

@nitindhar7
Copy link

@KrauseFx thanks for the fast fixes! works perfectly for me :)

@fastlane fastlane locked and limited conversation to collaborators Jan 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants