Skip to content

How can I add a custom attribute in REST API? #5747

Closed
@springimport

Description

@springimport

Question 1:

I'm trying place an order using Magento 2 API. I have a custom attribute that I want to submit along with this.
I tried submitting the custom attribute.

{
  "paymentMethod": {
    "poNumber": "1234567",
    "method": "purchaseorder"
  },
  "billingAddress": {
    "firstname": "Tom",
    "lastname": "Sawyer",
    "region": {
        "region_code": "NY",
        "region": "New York",
        "region_id": 43
    },
    "region_id": 43,
    "country_id": "US",
    "street": [
        "Main St"
    ],
    "telephone": "64868564631",
    "postcode": "11011",
    "city": "New York"
  },



  "order_date": "2003-01-16 23:12:01" // my custom attribute
}

But it comes back with the error below:

Property \"OrderDate\" does not have corresponding setter in class \"Magento\\Quote\\Api\\Data\\PaymentInterface\

Question 2:

I'm trying to add a custom field to the following:

  1. [GET] /V1/orders/{id}
  2. [GET] /V1/orders

How can I extend Magento\Sales\Api\Data\OrderInterface?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions