1

I have add field track_url in table sales_shipment_track. I'm creating shipment with API

http://192.168.0.105/magento2/project/rest/V1/order/1292/ship


{
  "items": [
    {
      "order_item_id": 4473,
      "qty": 1
    }
  ],
  "notify": true,
  "tracks": [
    {
      "track_number": "3456789",
      "track_url": "http://192.168.0.105/demo/magento2?gf=13131",
      "title": "GEODIS",
      "carrier_code": "custom"
    }
  ]
}

everything was working fine before added new field track_url.

Now i'm getting error. "message": "Property \"TrackUrl\" does not have corresponding setter in class \"Magento\\Sales\\Api\\Data\\ShipmentTrackCreationInterface\".",

How can i add extension attribute for it?

EDIT I have add attribute in extension_attributes.xml.How can i save it with API?

    <config>
    <extension_attributes for="Magento\Sales\Api\Data\OrderInterface">
        <attribute code="dpd_relay_id" type="string"/>
        <attribute code="erp_exported" type="string"/>
    </extension_attributes>

    <extension_attributes for="Magento\Catalog\Api\Data\ProductInterface">
        <attribute code="finalprice" type="string"/>
        <attribute code="brand" type="string"/>
    </extension_attributes>

     <extension_attributes for="Magento\Sales\Api\Data\ShipmentTrackCreationInterface">
        <attribute code="track_url" type="string"/>
    </extension_attributes>

</config>
1

Try with below request payload

{
  "items": [
    {
      "order_item_id": 4473,
      "qty": 1
    }
  ],
  "notify": true,
  "tracks": [
    {
      "track_number": "3456789",
      "title": "GEODIS",
      "carrier_code": "custom",
      "extension_attributes" : {
            "track_url": "http://192.168.0.105/demo/magento2?gf=13131"
      }
    }
  ]
}.

You need to update extension_attributes.xml file as well. As you have not defined the xsd in config node.

 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
    <extension_attributes for="Magento\Sales\Api\Data\OrderInterface">
        <attribute code="dpd_relay_id" type="string"/>
        <attribute code="erp_exported" type="string"/>
    </extension_attributes>

    <extension_attributes for="Magento\Catalog\Api\Data\ProductInterface">
        <attribute code="finalprice" type="string"/>
        <attribute code="brand" type="string"/>
    </extension_attributes>

     <extension_attributes for="Magento\Sales\Api\Data\ShipmentTrackCreationInterface">
        <attribute code="track_url" type="string"/>
    </extension_attributes>

</config>

Let me know if you need further help.

  • I need one more help please go this link "magento.stackexchange.com/questions/250625/… you have any idea reply me – Rv Singh Nov 23 '18 at 7:28
  • @Saniya, Where's Link !!!! – Vivek Nov 23 '18 at 7:29
  • "message": "Property \"TrackUrl\" does not have corresponding setter in class \"Magento\\Sales\\Api\\Data\\ShipmentTrackCreationExtensionInterface\".", getting this error – Ketan Borada Nov 23 '18 at 8:18
  • I am guessing you are on developer mode so just remove generated folder then check and before that update your question with complete extension_attribute.xml file and location. – Ramkishan Suthar Nov 23 '18 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.