CURL request using DELETE method in Magento 2Best Way to Load a Custom Model in Magento 2Price not getting updated for second product…Magento 2.1 Create a filter in the product grid by new attributeMagento 2 - Curl Method coding standard?Add CURLOPT_HTTPHEADER to Magento 2 curlcURL with Magento 2Magento 2 Rest Api call curl SSL ErrorForm is not displayed on panel admin Magento 2magento 2 : How to use curl?How to write Curl code to Magento 2 code

What is the difference between "Grippe" and "Männergrippe"?

What are some interesting features that are common cross-linguistically but don't exist in English?

How can I unambiguously ask for a new user's "Display Name"?

Is a player able to change alignment midway through an adventure?

Shouldn't the "credit score" prevent Americans from going deeper and deeper into personal debt?

Identify a problem where a potentially winning move draws because of the 50 move rule

If the first law of thermodynamics ensures conservation of energy, why does it allow systems to lose energy?

Pythagorean triple with hypotenuse a power of 2

How do I request a longer than normal leave of absence period for my wedding?

Compelling story with the world as a villain

If all stars rotate, why was there a theory developed that requires non-rotating stars?

Round towards zero

Why do all fields in a QFT transform like *irreducible* representations of some group?

How would one country purchase another?

Did the British navy fail to take into account the ballistics correction due to Coriolis force during WW1 Falkland Islands battle?

Understanding Parallelize methods

Prove your innocence

Justifying the use of directed energy weapons

Which household object drew this pattern?

French abbreviation for comparing two items ("vs")

How is the idea of "two people having a heated argument" idiomatically expressed in German?

State-of-the-art algorithms for solving linear programming problems

Sci fi film similar to Village of the Damned

Can't stopover at Sapporo when going from Asahikawa to Chitose airport?



CURL request using DELETE method in Magento 2


Best Way to Load a Custom Model in Magento 2Price not getting updated for second product…Magento 2.1 Create a filter in the product grid by new attributeMagento 2 - Curl Method coding standard?Add CURLOPT_HTTPHEADER to Magento 2 curlcURL with Magento 2Magento 2 Rest Api call curl SSL ErrorForm is not displayed on panel admin Magento 2magento 2 : How to use curl?How to write Curl code to Magento 2 code






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to call a curl request for delete method using MagentoFrameworkHTTPClientCurl.php.



In this class makeRequest method is responsible for sending curl request. But as I can see that this method is protected so I can't call it directly.



makeRequest method in MagentoFrameworkHTTPClientCurl.php



/**
* Make request
* @param string $method
* @param string $uri
* @param array $params
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function makeRequest($method, $uri, $params = [])

$this->_ch = curl_init();
$this->curlOption(CURLOPT_URL, $uri);
if ($method == 'POST')
$this->curlOption(CURLOPT_POST, 1);
$this->curlOption(CURLOPT_POSTFIELDS, http_build_query($params));
elseif ($method == "GET")
$this->curlOption(CURLOPT_HTTPGET, 1);
else
$this->curlOption(CURLOPT_CUSTOMREQUEST, $method);


if (count($this->_headers))
$heads = [];
foreach ($this->_headers as $k => $v)
$heads[] = $k . ': ' . $v;

$this->curlOption(CURLOPT_HTTPHEADER, $heads);


if (count($this->_cookies))
$cookies = [];
foreach ($this->_cookies as $k => $v)
$cookies[] = "$k=$v";

$this->curlOption(CURLOPT_COOKIE, implode(";", $cookies));


if ($this->_timeout)
$this->curlOption(CURLOPT_TIMEOUT, $this->_timeout);


if ($this->_port != 80)
$this->curlOption(CURLOPT_PORT, $this->_port);


//$this->curlOption(CURLOPT_HEADER, 1);
$this->curlOption(CURLOPT_RETURNTRANSFER, 1);
$this->curlOption(CURLOPT_HEADERFUNCTION, [$this, 'parseHeaders']);

if (count($this->_curlUserOptions))
foreach ($this->_curlUserOptions as $k => $v)
$this->curlOption($k, $v);



$this->_headerCount = 0;
$this->_responseHeaders = [];
$this->_responseBody = curl_exec($this->_ch);
$err = curl_errno($this->_ch);
if ($err)
$this->doError(curl_error($this->_ch));

curl_close($this->_ch);



I have to call one of public method of this class which is calling makeRequest method.
When I check this I can see 2 public methods for GET and POST request which are calling protected method makeRequest. No other method for DELETE which is calling method makeRequest.



/**
* Make GET request
*
* @param string $uri uri relative to host, ex. "/index.php"
* @return void
*/
public function get($uri)

$this->makeRequest("GET", $uri);


/**
* Make POST request
*
* @param string $uri
* @param array $params
* @return void
*
* @see MagentoFrameworkHTTPClient#post($uri, $params)
*/
public function post($uri, $params)

$this->makeRequest("POST", $uri, $params);



Now my question is that how can I solve my problem or is this bug in magento 2.1.7 or may be I am getting incorrectly. Please help me if I am doing anything wrong.



class reference curl.php










share|improve this question
































    0















    I am trying to call a curl request for delete method using MagentoFrameworkHTTPClientCurl.php.



    In this class makeRequest method is responsible for sending curl request. But as I can see that this method is protected so I can't call it directly.



    makeRequest method in MagentoFrameworkHTTPClientCurl.php



    /**
    * Make request
    * @param string $method
    * @param string $uri
    * @param array $params
    * @return void
    * @SuppressWarnings(PHPMD.CyclomaticComplexity)
    * @SuppressWarnings(PHPMD.NPathComplexity)
    */
    protected function makeRequest($method, $uri, $params = [])

    $this->_ch = curl_init();
    $this->curlOption(CURLOPT_URL, $uri);
    if ($method == 'POST')
    $this->curlOption(CURLOPT_POST, 1);
    $this->curlOption(CURLOPT_POSTFIELDS, http_build_query($params));
    elseif ($method == "GET")
    $this->curlOption(CURLOPT_HTTPGET, 1);
    else
    $this->curlOption(CURLOPT_CUSTOMREQUEST, $method);


    if (count($this->_headers))
    $heads = [];
    foreach ($this->_headers as $k => $v)
    $heads[] = $k . ': ' . $v;

    $this->curlOption(CURLOPT_HTTPHEADER, $heads);


    if (count($this->_cookies))
    $cookies = [];
    foreach ($this->_cookies as $k => $v)
    $cookies[] = "$k=$v";

    $this->curlOption(CURLOPT_COOKIE, implode(";", $cookies));


    if ($this->_timeout)
    $this->curlOption(CURLOPT_TIMEOUT, $this->_timeout);


    if ($this->_port != 80)
    $this->curlOption(CURLOPT_PORT, $this->_port);


    //$this->curlOption(CURLOPT_HEADER, 1);
    $this->curlOption(CURLOPT_RETURNTRANSFER, 1);
    $this->curlOption(CURLOPT_HEADERFUNCTION, [$this, 'parseHeaders']);

    if (count($this->_curlUserOptions))
    foreach ($this->_curlUserOptions as $k => $v)
    $this->curlOption($k, $v);



    $this->_headerCount = 0;
    $this->_responseHeaders = [];
    $this->_responseBody = curl_exec($this->_ch);
    $err = curl_errno($this->_ch);
    if ($err)
    $this->doError(curl_error($this->_ch));

    curl_close($this->_ch);



    I have to call one of public method of this class which is calling makeRequest method.
    When I check this I can see 2 public methods for GET and POST request which are calling protected method makeRequest. No other method for DELETE which is calling method makeRequest.



    /**
    * Make GET request
    *
    * @param string $uri uri relative to host, ex. "/index.php"
    * @return void
    */
    public function get($uri)

    $this->makeRequest("GET", $uri);


    /**
    * Make POST request
    *
    * @param string $uri
    * @param array $params
    * @return void
    *
    * @see MagentoFrameworkHTTPClient#post($uri, $params)
    */
    public function post($uri, $params)

    $this->makeRequest("POST", $uri, $params);



    Now my question is that how can I solve my problem or is this bug in magento 2.1.7 or may be I am getting incorrectly. Please help me if I am doing anything wrong.



    class reference curl.php










    share|improve this question




























      0












      0








      0








      I am trying to call a curl request for delete method using MagentoFrameworkHTTPClientCurl.php.



      In this class makeRequest method is responsible for sending curl request. But as I can see that this method is protected so I can't call it directly.



      makeRequest method in MagentoFrameworkHTTPClientCurl.php



      /**
      * Make request
      * @param string $method
      * @param string $uri
      * @param array $params
      * @return void
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      * @SuppressWarnings(PHPMD.NPathComplexity)
      */
      protected function makeRequest($method, $uri, $params = [])

      $this->_ch = curl_init();
      $this->curlOption(CURLOPT_URL, $uri);
      if ($method == 'POST')
      $this->curlOption(CURLOPT_POST, 1);
      $this->curlOption(CURLOPT_POSTFIELDS, http_build_query($params));
      elseif ($method == "GET")
      $this->curlOption(CURLOPT_HTTPGET, 1);
      else
      $this->curlOption(CURLOPT_CUSTOMREQUEST, $method);


      if (count($this->_headers))
      $heads = [];
      foreach ($this->_headers as $k => $v)
      $heads[] = $k . ': ' . $v;

      $this->curlOption(CURLOPT_HTTPHEADER, $heads);


      if (count($this->_cookies))
      $cookies = [];
      foreach ($this->_cookies as $k => $v)
      $cookies[] = "$k=$v";

      $this->curlOption(CURLOPT_COOKIE, implode(";", $cookies));


      if ($this->_timeout)
      $this->curlOption(CURLOPT_TIMEOUT, $this->_timeout);


      if ($this->_port != 80)
      $this->curlOption(CURLOPT_PORT, $this->_port);


      //$this->curlOption(CURLOPT_HEADER, 1);
      $this->curlOption(CURLOPT_RETURNTRANSFER, 1);
      $this->curlOption(CURLOPT_HEADERFUNCTION, [$this, 'parseHeaders']);

      if (count($this->_curlUserOptions))
      foreach ($this->_curlUserOptions as $k => $v)
      $this->curlOption($k, $v);



      $this->_headerCount = 0;
      $this->_responseHeaders = [];
      $this->_responseBody = curl_exec($this->_ch);
      $err = curl_errno($this->_ch);
      if ($err)
      $this->doError(curl_error($this->_ch));

      curl_close($this->_ch);



      I have to call one of public method of this class which is calling makeRequest method.
      When I check this I can see 2 public methods for GET and POST request which are calling protected method makeRequest. No other method for DELETE which is calling method makeRequest.



      /**
      * Make GET request
      *
      * @param string $uri uri relative to host, ex. "/index.php"
      * @return void
      */
      public function get($uri)

      $this->makeRequest("GET", $uri);


      /**
      * Make POST request
      *
      * @param string $uri
      * @param array $params
      * @return void
      *
      * @see MagentoFrameworkHTTPClient#post($uri, $params)
      */
      public function post($uri, $params)

      $this->makeRequest("POST", $uri, $params);



      Now my question is that how can I solve my problem or is this bug in magento 2.1.7 or may be I am getting incorrectly. Please help me if I am doing anything wrong.



      class reference curl.php










      share|improve this question
















      I am trying to call a curl request for delete method using MagentoFrameworkHTTPClientCurl.php.



      In this class makeRequest method is responsible for sending curl request. But as I can see that this method is protected so I can't call it directly.



      makeRequest method in MagentoFrameworkHTTPClientCurl.php



      /**
      * Make request
      * @param string $method
      * @param string $uri
      * @param array $params
      * @return void
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      * @SuppressWarnings(PHPMD.NPathComplexity)
      */
      protected function makeRequest($method, $uri, $params = [])

      $this->_ch = curl_init();
      $this->curlOption(CURLOPT_URL, $uri);
      if ($method == 'POST')
      $this->curlOption(CURLOPT_POST, 1);
      $this->curlOption(CURLOPT_POSTFIELDS, http_build_query($params));
      elseif ($method == "GET")
      $this->curlOption(CURLOPT_HTTPGET, 1);
      else
      $this->curlOption(CURLOPT_CUSTOMREQUEST, $method);


      if (count($this->_headers))
      $heads = [];
      foreach ($this->_headers as $k => $v)
      $heads[] = $k . ': ' . $v;

      $this->curlOption(CURLOPT_HTTPHEADER, $heads);


      if (count($this->_cookies))
      $cookies = [];
      foreach ($this->_cookies as $k => $v)
      $cookies[] = "$k=$v";

      $this->curlOption(CURLOPT_COOKIE, implode(";", $cookies));


      if ($this->_timeout)
      $this->curlOption(CURLOPT_TIMEOUT, $this->_timeout);


      if ($this->_port != 80)
      $this->curlOption(CURLOPT_PORT, $this->_port);


      //$this->curlOption(CURLOPT_HEADER, 1);
      $this->curlOption(CURLOPT_RETURNTRANSFER, 1);
      $this->curlOption(CURLOPT_HEADERFUNCTION, [$this, 'parseHeaders']);

      if (count($this->_curlUserOptions))
      foreach ($this->_curlUserOptions as $k => $v)
      $this->curlOption($k, $v);



      $this->_headerCount = 0;
      $this->_responseHeaders = [];
      $this->_responseBody = curl_exec($this->_ch);
      $err = curl_errno($this->_ch);
      if ($err)
      $this->doError(curl_error($this->_ch));

      curl_close($this->_ch);



      I have to call one of public method of this class which is calling makeRequest method.
      When I check this I can see 2 public methods for GET and POST request which are calling protected method makeRequest. No other method for DELETE which is calling method makeRequest.



      /**
      * Make GET request
      *
      * @param string $uri uri relative to host, ex. "/index.php"
      * @return void
      */
      public function get($uri)

      $this->makeRequest("GET", $uri);


      /**
      * Make POST request
      *
      * @param string $uri
      * @param array $params
      * @return void
      *
      * @see MagentoFrameworkHTTPClient#post($uri, $params)
      */
      public function post($uri, $params)

      $this->makeRequest("POST", $uri, $params);



      Now my question is that how can I solve my problem or is this bug in magento 2.1.7 or may be I am getting incorrectly. Please help me if I am doing anything wrong.



      class reference curl.php







      magento-2.1 delete methods curl-request






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 19 '17 at 8:13









      Prince Patel

      15.1k7 gold badges59 silver badges86 bronze badges




      15.1k7 gold badges59 silver badges86 bronze badges










      asked Aug 19 '17 at 7:57









      Ramkishan SutharRamkishan Suthar

      2,5192 gold badges14 silver badges37 bronze badges




      2,5192 gold badges14 silver badges37 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          0















          Use this object instead:



          $request = new ZendHttpRequest();


          Then set the method to



          $request->setMethod(ZendHttpRequest::METHOD_DELETE);


          For more information, read the tutorial in the following link:
          http://devdocs.magento.com/guides/v2.1/get-started/gs-web-api-request.html






          share|improve this answer

























          • hello @Toan Tam, I am not sure if we can use it for curl request ?

            – Ramkishan Suthar
            Aug 19 '17 at 12:24











          • I think it is for rest api calls.

            – Ramkishan Suthar
            Aug 19 '17 at 12:27











          • The main purpose of curl request is to make a http request. And the ZendHttpRequest() class is suitable in this case.

            – Toan Tam
            Aug 19 '17 at 12:46











          • ok then let me try

            – Ramkishan Suthar
            Aug 19 '17 at 13:00













          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f189752%2fcurl-request-using-delete-method-in-magento-2%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0















          Use this object instead:



          $request = new ZendHttpRequest();


          Then set the method to



          $request->setMethod(ZendHttpRequest::METHOD_DELETE);


          For more information, read the tutorial in the following link:
          http://devdocs.magento.com/guides/v2.1/get-started/gs-web-api-request.html






          share|improve this answer

























          • hello @Toan Tam, I am not sure if we can use it for curl request ?

            – Ramkishan Suthar
            Aug 19 '17 at 12:24











          • I think it is for rest api calls.

            – Ramkishan Suthar
            Aug 19 '17 at 12:27











          • The main purpose of curl request is to make a http request. And the ZendHttpRequest() class is suitable in this case.

            – Toan Tam
            Aug 19 '17 at 12:46











          • ok then let me try

            – Ramkishan Suthar
            Aug 19 '17 at 13:00















          0















          Use this object instead:



          $request = new ZendHttpRequest();


          Then set the method to



          $request->setMethod(ZendHttpRequest::METHOD_DELETE);


          For more information, read the tutorial in the following link:
          http://devdocs.magento.com/guides/v2.1/get-started/gs-web-api-request.html






          share|improve this answer

























          • hello @Toan Tam, I am not sure if we can use it for curl request ?

            – Ramkishan Suthar
            Aug 19 '17 at 12:24











          • I think it is for rest api calls.

            – Ramkishan Suthar
            Aug 19 '17 at 12:27











          • The main purpose of curl request is to make a http request. And the ZendHttpRequest() class is suitable in this case.

            – Toan Tam
            Aug 19 '17 at 12:46











          • ok then let me try

            – Ramkishan Suthar
            Aug 19 '17 at 13:00













          0














          0










          0









          Use this object instead:



          $request = new ZendHttpRequest();


          Then set the method to



          $request->setMethod(ZendHttpRequest::METHOD_DELETE);


          For more information, read the tutorial in the following link:
          http://devdocs.magento.com/guides/v2.1/get-started/gs-web-api-request.html






          share|improve this answer













          Use this object instead:



          $request = new ZendHttpRequest();


          Then set the method to



          $request->setMethod(ZendHttpRequest::METHOD_DELETE);


          For more information, read the tutorial in the following link:
          http://devdocs.magento.com/guides/v2.1/get-started/gs-web-api-request.html







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 19 '17 at 11:25









          Toan TamToan Tam

          6394 silver badges17 bronze badges




          6394 silver badges17 bronze badges















          • hello @Toan Tam, I am not sure if we can use it for curl request ?

            – Ramkishan Suthar
            Aug 19 '17 at 12:24











          • I think it is for rest api calls.

            – Ramkishan Suthar
            Aug 19 '17 at 12:27











          • The main purpose of curl request is to make a http request. And the ZendHttpRequest() class is suitable in this case.

            – Toan Tam
            Aug 19 '17 at 12:46











          • ok then let me try

            – Ramkishan Suthar
            Aug 19 '17 at 13:00

















          • hello @Toan Tam, I am not sure if we can use it for curl request ?

            – Ramkishan Suthar
            Aug 19 '17 at 12:24











          • I think it is for rest api calls.

            – Ramkishan Suthar
            Aug 19 '17 at 12:27











          • The main purpose of curl request is to make a http request. And the ZendHttpRequest() class is suitable in this case.

            – Toan Tam
            Aug 19 '17 at 12:46











          • ok then let me try

            – Ramkishan Suthar
            Aug 19 '17 at 13:00
















          hello @Toan Tam, I am not sure if we can use it for curl request ?

          – Ramkishan Suthar
          Aug 19 '17 at 12:24





          hello @Toan Tam, I am not sure if we can use it for curl request ?

          – Ramkishan Suthar
          Aug 19 '17 at 12:24













          I think it is for rest api calls.

          – Ramkishan Suthar
          Aug 19 '17 at 12:27





          I think it is for rest api calls.

          – Ramkishan Suthar
          Aug 19 '17 at 12:27













          The main purpose of curl request is to make a http request. And the ZendHttpRequest() class is suitable in this case.

          – Toan Tam
          Aug 19 '17 at 12:46





          The main purpose of curl request is to make a http request. And the ZendHttpRequest() class is suitable in this case.

          – Toan Tam
          Aug 19 '17 at 12:46













          ok then let me try

          – Ramkishan Suthar
          Aug 19 '17 at 13:00





          ok then let me try

          – Ramkishan Suthar
          Aug 19 '17 at 13:00

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f189752%2fcurl-request-using-delete-method-in-magento-2%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

          Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

          Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림