magento2: V1/carts/mine/billing-address returning %fieldName is a required field.

Preconditions

  1. Magento EE 2.1.1
  2. PHP 7.0.12
  3. Mysql Ver 14.14 Distrib 5.6.33-79.0, for Linux (x86_64) using 6.2

Steps to reproduce

    1. Go to the checkout after adding something to the basket
    1. Send a request to the REST endpoint V1/carts/mine/billing-address using the payload below
{"cartId":"190488","address":{"countryId":"GB","regionId":"0","region":"","street":["54 Carnegie Court",""],"company":"","telephone":"0165 4569 8754","fax":"","postcode":"AB1C 2DF","city":"SomeCity","firstname":"Bob","lastname":"White","save_in_address_book":1,"saveInAddressBook":null}}

Note that this api endpoint is used by the module ebizmarts/sagepaysuite for the payment option SagePay

Actual result

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

Note that cartId is in the payload but the parameter validation fails.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 24 (7 by maintainers)

Most upvoted comments

Hi

i fixed this issue. Below is the fix for this issue.

  1. pass cartId in the below js after line no. file : Magento_Checkout\web\js\model\shipping-rate-processor\customer-address.js

                storage.post(
                    resourceUrlManager.getUrlForEstimationShippingMethodsByAddressId(quote),
                    JSON.stringify({
                        addressId: address.customerAddressId,
    	    cartId: quote.getQuoteId()
                    }),
                    false
                )
    
  2. Prevent cartId param removal by adding a plugin for the below method

File : \Magento\Webapi\Controller\Rest\ParamsOverrider

plugin

public function aroundoverride(\Magento\Webapi\Controller\Rest\ParamsOverrider $ParamsOverrider,\Closure $proceed,array $inputData, array $parameters)
{
	if(isset($inputData['cartId'])){$cartid = $inputData['cartId'];}		
	$result = $proceed($inputData,$parameters);
	if(isset($cartid)){$result['cartId'] = $cartid;}
	return $result;		
}

Has anyone found the solution with this issue yet? I am using Magento 2…2.8 and I still have this problem