0

I have created a custom api and add some getters and setter, I'm looking to find out if it's possible to pass key pair values in the post without having to set the setters. When I call the api I get an exception and in my exception log:

...Message: Property "MyItemId" does not have corresponding setter in 
class "Vendor\Module\Api\CustomRefundInterface"...

My request:

{
    "test": [
        {
            "MyItemId": "157061",
            "Quantity": "1",
            "Amount": "44.99",
            "MoreStuf": {
                "Code": "200",
                "Name": "OK"
            },
            "comments": "Just another Comment"
        }
    ]
}

Can I send any key pair value without having to worry about the setters and how?

Any help Thanks

0

I have found how to pass just the post values and not having to create setters for each field. in my CustomRefundInterface I've had a doc block like so:

/**
 * @api
 * @param \Vendor\Moduel\Model\CustomRefund[] $test
 * @return string
 */

All I had to do is change param $test to mixed and it worked:

/**
 * @api
 * @param mixed $test
 * @return string
 */

Just to note: this will return the post array instead of and array of class object:

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.