getting error when try to save shipping information for user using magento 2 api

6.1k Views Asked by At

Can not able to save the shipping information after process from cart to checkout . We are using magento 2 api. My post information is like that

{
"addressInformation": {
"shipping_address": {
"id": 0,
"region": "IND",
"region_id": 0,
"region_code": "string",
"country_id": "IN",
"street": [
"string"
],
"company": "string",
"telephone": "123456789",
"fax": "string",
"postcode": "700091",
"city": "Kolkata",
"firstname": "Sauptik",
"lastname": "Basak",
"middlename": "string",
"prefix": "string",
"suffix": "string",
"vat_id": "string",
"customer_id": 2,
"email": "[email protected]",
"same_as_billing": 0,
"customer_address_id": 0,
"save_in_address_book": 1,      
"custom_attributes": [
{
"attribute_code": "string",
"value": "string"
}
]
},
"billing_address": {
"id": 0,
"region": "string",
"region_id": 0,
"region_code": "string",
"country_id": "IN",
"street": [
"string"
],
"company": "string",
"telephone": "123456789",
"fax": "string",
"postcode": "700091",
"city": "Kolkata",
"firstname": "Sauptik",
"lastname": "Basak",
"middlename": "string",
"prefix": "string",
"suffix": "string",
"vat_id": "string",
"customer_id": 2,
"email": "string",
"same_as_billing": 0,
"customer_address_id": 0,
"save_in_address_book": 0,      
"custom_attributes": [
{
"attribute_code": "string",
"value": "string"
}
]
},
"shipping_method_code": "string",
"shipping_carrier_code": "string",
"extension_attributes": {},
"custom_attributes": [
{
"attribute_code": "string",
"value": "string"
}
]
}
}

my end point is http://192.168.0.61/WallisFudge/index.php/rest/V1/carts/3/shipping-information

i am getting that error

"message": "Unable to save shipping information. Please check input data."

can not able to process checkout through magento 2 api

3

There are 3 best solutions below

0
On

Can you try retrieving your available "Shipping Methods" by calling http://192.168.0.61/WallisFudge/index.php/rest/V1/carts/3/shipping-methods. Then get the data and assign the codes to the following:

"shipping_method_code": "your_shipping_method_code_here", "shipping_carrier_code": "your_shipping_carrier_code_here",

Hope this helps.

Joemar

0
On

I was getting this issue after upgrading Magento version from 2.1.9 to 2.2.3

It happens at one of these places:

  • I add the product to cart.
  • On checkout page, if I click on Place Order button

So it throws below error:

Unable to save address. Please check input data.

I did following on server: On Plesk I had to change the include_path for php from

.:/opt/plesk/php/7.0/share/pear

to

.:/var/www/vhosts/mysitehomedir/vendor/magento/zendframework1/library

Saved changes and then restarted apache. Then flushed Magento Cache, and then my problem resolved.

I hope it would help you as well!

2
On

I encountered this error message on the checkout page at the shipping step for a registered customer. After looking at the exception log, the following was captured:

report.CRITICAL: Invalid customer address id ##### {"exception":"[object] (Magento\\Framework\\Exception\\NoSuchEntityException(code: 0): Invalid customer address id ##### at /app/vlegfavdpg4my/vendor/magento/module-quote/Model/QuoteAddressValidator.php:77)"}

After examined the code, line 77 is an exception threw from customer ID check:

//Existing address cannot belong to a guest
if (!$customerId) {
  throw new NoSuchEntityException(__('Invalid customer address id %1', $address->getCustomerAddressId()));
}

This is a private function that's called by a public function within the class:

public function validate(AddressInterface $addressData): bool
{
  $this->doValidate($addressData, $addressData->getCustomerId());
  return true;
}

At this point, it looks like the customer ID being referenced in the address object appears to be null or empty. It turns out a guest quote associated was associated to this registered customer.

To correct this behaviour, first query for the quotes suffering this symptoms:

SELECT entity_id, customer_id FROM quote WHERE customer_id != 0 AND customer_is_guest = 1;

If the customer ID is returning in the result set, update ALL quotes to NOT guest customer for those that are registered customer quote:

UPDATE quote SET customer_is_guest = 0 WHERE customer_id != 0 AND customer_is_guest = 1;

This solved my customer's issue. The order can now proceed to the payment step.

My current version is 2.2.9 but possibly exist in the earlier version 2.2.x.