grayloon / magento-laravel-api

A simple Magento 2 REST API Object Oriented wrapper for Laravel applications.
MIT License
63 stars 46 forks source link

Posting data into magento. #85

Closed vimal-360 closed 2 years ago

vimal-360 commented 2 years ago

Hello.

I am trying to post categories to magento using laravel. I found that this post, put, delete methods are protected. I can not use. Is there any other way? or why it is protected


$magento->api('categories')->post('/',$categoryArray);

  /**
     * Send a POST request with query parameters.
     *
     * @param  string  $path
     * @param  string  $parameters
     * @return \Illuminate\Http\Client\Response
     */
    protected function post($path, $parameters = [])
    {
        return $this->checkExceptions(Http::withToken($this->magento->token)
            ->post($this->apiRequest.$path, $parameters), $this->apiRequest.$path, $parameters);
    }
ahinkle commented 2 years ago

Hi @vimal-360,

We currently don't have active support on that post endpoint. Only to pull all (index via GET) categories; feel free to send a PR.

The protected post method is intentional; these are for custom endpoints. I would not recommend your method for making API calls. Please refer to the documentation. If you need a workaround for posting to categories, you could use Laravel's HTTP client to make a post request to your endpoint.

Something like this:

$response = Http::post('http://my-magento-shop.com/rest/default/V1/categories/', $payload);

Thanks