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

GET /V1/carts/mine/items is returning "cartId is a required field" #1443

Closed
sauberia opened this issue Jul 5, 2015 · 7 comments
Closed

GET /V1/carts/mine/items is returning "cartId is a required field" #1443

sauberia opened this issue Jul 5, 2015 · 7 comments
Labels
bug report Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Progress: needs update

Comments

@sauberia
Copy link

sauberia commented Jul 5, 2015

The webapi.xml for Quote specifies the getList method but I believe this should be getListForCustomer instead.

    <route url="/V1/carts/mine/items" method="GET">
        <service class="Magento\Quote\Api\CartItemRepositoryInterface" method="getList"/>
        <resources>
            <resource ref="self" />
        </resources>
        <data>
            <parameter name="customerId" force="true">%customer_id%</parameter>
        </data>
    </route>

Likewise, PUT /V1/carts/mine/items/:itemId should use saveForCustomer and DELETE /V1/carts/mine/items/:itemId should use deleteByIdForCustomer.


Here is a ruby hash of the the request and response:

{
            :method => :get,
              :body => "{\"message\":\"%fieldName is a required field.\",\"parameters\":{\"fieldName\":\"cartId\"}}",
               :url => #<URI::HTTP http://localhost/magento2/rest/V1/carts/mine/items>,
           :request => {
    :params_encoder => nil,
             :proxy => nil,
              :bind => nil,
           :timeout => nil,
      :open_timeout => nil,
          :boundary => nil,
             :oauth => nil
  },
   :request_headers => {
       "User-Agent" => "Faraday v0.9.1",
    "Authorization" => "Bearer e9txps1sw6mrv1qf48ihrrx9rtku3uj2",
     "Content-Type" => "application/json"
  },
               :ssl => {
          :verify => nil,
         :ca_file => nil,
         :ca_path => nil,
     :verify_mode => nil,
      :cert_store => nil,
     :client_cert => nil,
      :client_key => nil,
     :certificate => nil,
     :private_key => nil,
    :verify_depth => nil,
         :version => nil
  },
  :response_headers => {
              "date" => "Sun, 05 Jul 2015 16:31:00 GMT",
            "server" => "Apache/2.2.26 (Unix) DAV/2 PHP/5.6.10 mod_ssl/2.2.26 OpenSSL/0.9.8za",
      "x-powered-by" => "PHP/5.6.10",
        "set-cookie" => "PHPSESSID=ou53q01g0kvemeq6dm1ho2r7b0; expires=Sun, 05-Jul-2015 17:31:01 GMT; Max-Age=3600; path=/magento2; domain=localhost; HttpOnly",
           "expires" => "Thu, 19 Nov 1981 08:52:00 GMT",
     "cache-control" => "no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
            "pragma" => "no-cache",
    "content-length" => "81",
        "connection" => "close",
      "content-type" => "application/json; charset=utf-8"
  },
            :status => 400
}
@sauberia
Copy link
Author

sauberia commented Jul 5, 2015

Just to demonstrate that the web API token authorisation is working, here is a request for the authenticated customer's cart:

{
            :method => :get,
              :body => "{\"id\":1,\"created_at\":\"2015-07-05 17:30:40\",\"updated_at\":\"0000-00-00 00:00:00\",\"is_active\":true,\"is_virtual\":false,\"items_count\":0,\"items_qty\":0,\"customer\":{\"id\":1,\"group_id\":1,\"created_at\":\"2015-07-05 16:29:15\",\"created_in\":\"Default Store View\",\"email\":\"marc@marctauber.com\",\"firstname\":\"Marc\",\"lastname\":\"Tauber\",\"store_id\":1,\"website_id\":1,\"addresses\":[],\"disable_auto_group_change\":0},\"checkout_method\":\"login_in\",\"shipping_address\":{\"region\":null,\"region_id\":null,\"region_code\":null,\"country_id\":null,\"street\":[\"\"],\"telephone\":null,\"postcode\":null,\"city\":null,\"firstname\":null,\"lastname\":null,\"email\":\"marc@marctauber.com\"},\"billing_address\":{\"region\":null,\"region_id\":null,\"region_code\":null,\"country_id\":null,\"street\":[\"\"],\"telephone\":null,\"postcode\":null,\"city\":null,\"firstname\":null,\"lastname\":null,\"email\":\"marc@marctauber.com\"},\"orig_order_id\":0,\"currency\":{\"global_currency_code\":\"GBP\",\"base_currency_code\":\"GBP\",\"store_currency_code\":\"GBP\",\"quote_currency_code\":\"GBP\",\"store_to_base_rate\":0,\"store_to_quote_rate\":0,\"base_to_global_rate\":1,\"base_to_quote_rate\":1},\"customer_is_guest\":false,\"customer_note_notify\":true,\"customer_tax_class_id\":3,\"store_id\":1}",
               :url => #<URI::HTTP http://localhost/magento2/rest/V1/carts/mine>,
           :request => {
    :params_encoder => nil,
             :proxy => nil,
              :bind => nil,
           :timeout => nil,
      :open_timeout => nil,
          :boundary => nil,
             :oauth => nil
  },
   :request_headers => {
       "User-Agent" => "Faraday v0.9.1",
    "Authorization" => "Bearer e9txps1sw6mrv1qf48ihrrx9rtku3uj2",
     "Content-Type" => "application/json"
  },
               :ssl => {
          :verify => nil,
         :ca_file => nil,
         :ca_path => nil,
     :verify_mode => nil,
      :cert_store => nil,
     :client_cert => nil,
      :client_key => nil,
     :certificate => nil,
     :private_key => nil,
    :verify_depth => nil,
         :version => nil
  },
  :response_headers => {
              "date" => "Sun, 05 Jul 2015 16:52:24 GMT",
            "server" => "Apache/2.2.26 (Unix) DAV/2 PHP/5.6.10 mod_ssl/2.2.26 OpenSSL/0.9.8za",
      "x-powered-by" => "PHP/5.6.10",
        "set-cookie" => "PHPSESSID=a0mbekqfjqnbpd89o0vq6k0hm4; expires=Sun, 05-Jul-2015 17:52:24 GMT; Max-Age=3600; path=/magento2; domain=localhost; HttpOnly",
           "expires" => "Thu, 19 Nov 1981 08:52:00 GMT",
     "cache-control" => "no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
            "pragma" => "no-cache",
    "content-length" => "1168",
        "connection" => "close",
      "content-type" => "application/json; charset=utf-8"
  },
            :status => 200
}

@vpelipenko vpelipenko added CS bug report Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Jul 6, 2015
@vpelipenko
Copy link
Contributor

Internal ticket: MAGETWO-39766

magento-team pushed a commit that referenced this issue Jul 31, 2015
magento-team pushed a commit that referenced this issue Jul 31, 2015
magento-team pushed a commit that referenced this issue Jul 31, 2015
@vpelipenko
Copy link
Contributor

@sauberia, issue is fixed and available in develop branch. Please, check the fix and let us know if it doesn't work for you.

@thdoan
Copy link

thdoan commented Apr 25, 2017

I just encountered this issue in Magento 2.1.5 when checking out as a registered user with a saved address. It is preventing the user from selecting a shipping method. I have traced the error to a 400 Bad Request...

Request URL = .../rest/us/V1/carts/mine/estimate-shipping-methods-by-address-id
Request Payload = {addressId: "60"}
Response:

{"message":"%fieldName is a required field.","parameters":{"fieldName":"cartId"},"trace":"#0 \/path\/to\/docroot\/vendor\/magento\/framework\/Webapi\/ServiceInputProcessor.php(131): Magento\\Framework\\Webapi\\ServiceInputProcessor->processInputError(Array)\n#1 \/path\/to\/docroot\/vendor\/magento\/module-webapi\/Controller\/Rest\/InputParamsResolver.php(101): Magento\\Framework\\Webapi\\ServiceInputProcessor->process('Magento\\\\Quote\\\\A...', 'estimateByAddre...', Array)\n#2 \/path\/to\/docroot\/vendor\/magento\/module-webapi\/Controller\/Rest.php(299): Magento\\Webapi\\Controller\\Rest\\InputParamsResolver->resolve()\n#3 \/path\/to\/docroot\/vendor\/magento\/module-webapi\/Controller\/Rest.php(216): Magento\\Webapi\\Controller\\Rest->processApiRequest()\n#4 \/path\/to\/docroot\/vendor\/magento\/framework\/Interception\/Interceptor.php(146): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#5 \/path\/to\/docroot\/var\/generation\/Magento\/Webapi\/Controller\/Rest\/Interceptor.php(39): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callPlugins('dispatch', Array, Array)\n#6 \/path\/to\/docroot\/vendor\/magento\/framework\/App\/Http.php(135): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#7 \/path\/to\/docroot\/vendor\/magento\/framework\/App\/Bootstrap.php(258): Magento\\Framework\\App\\Http->launch()\n#8 \/path\/to\/docroot\/index.php(52): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http))\n#9 {main}"}

@wrock
Copy link

wrock commented May 23, 2017

I also encounter this issue eventually on Magento 2.1.3

@sydekumf
Copy link

I have the same error and debugged it. In the end there is something else wrong which I described here: #9744
It is because Magento hides the exception...

@MikeSheward
Copy link

I'm also getting this error, probably from #9744, any ideas how to resolve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Progress: needs update
Projects
None yet
Development

No branches or pull requests

6 participants