Etsy file upload (curl) Err: Request body is too large












0















There are few practically the same questions but no good answer.
I have to send images to Etsy endpoint.



Decided to use lusitanian library found on git. It internally uses curl to make POST request.



Constantly get "The request body is too large" response.



Code:



$data = [
//'@image' => new CURLFile($imagePath, $mime, $imageFilename),
'@image' => '@'.$imagePath.';type='.$mime,
];

try {
$response = $etsyService->request(
$this->uri . '/' . $listingId . '/images',
'POST',
$data,
array(
'Content-Type'=>'multipart/form-data'
);
var_dump($response);die;
} catch (Exception $e) {
var_dump($e->getMessage());
}


Internally lusitanian uses this:



curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);


to make a request. Tried both from above $data.



Does anybody know how to solve this?



EDIT:



var_dump of header (curl_setopt($ch, CURLINFO_HEADER_OUT, true);)



    array (size=27)
'url' => string 'https://openapi.etsy.com/v2/listings/645283994/images' (length=53)
'content_type' => string 'text/plain;charset=UTF-8' (length=24)
'http_code' => int 400
'header_size' => int 895
'request_size' => int 590
'filetime' => int -1
'ssl_verify_result' => int 0
'redirect_count' => int 0
'total_time' => float 0.234278
'namelookup_time' => float 3.9E-5
'connect_time' => float 0.023493
'pretransfer_time' => float 0.083739
'size_upload' => float 105
'size_download' => float 29
'speed_download' => float 123
'speed_upload' => float 448
'download_content_length' => float 29
'upload_content_length' => float 105
'starttransfer_time' => float 0.234254
'redirect_time' => float 0
'redirect_url' => string '' (length=0)
'primary_ip' => string '151.101.13.224' (length=14)
'certinfo' =>
array (size=0)
empty
'primary_port' => int 443
'local_ip' => string '192.168.2.73' (length=12)
'local_port' => int 40466
'request_header' => string 'POST /v2/listings/645283994/images HTTP/1.1

Host: openapi.etsy.com

User-Agent: PHPoAuthLib

Accept: */*

Authorization: OAuth oauth_consumer_key="**************************", oauth_nonce="****************************8", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1542272124", oauth_version="1.0", oauth_token="*************", oauth_signature="******************"
Content-type: multipart/form-data
Connection: close
Content-Length: 105









share|improve this question





























    0















    There are few practically the same questions but no good answer.
    I have to send images to Etsy endpoint.



    Decided to use lusitanian library found on git. It internally uses curl to make POST request.



    Constantly get "The request body is too large" response.



    Code:



    $data = [
    //'@image' => new CURLFile($imagePath, $mime, $imageFilename),
    '@image' => '@'.$imagePath.';type='.$mime,
    ];

    try {
    $response = $etsyService->request(
    $this->uri . '/' . $listingId . '/images',
    'POST',
    $data,
    array(
    'Content-Type'=>'multipart/form-data'
    );
    var_dump($response);die;
    } catch (Exception $e) {
    var_dump($e->getMessage());
    }


    Internally lusitanian uses this:



    curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);


    to make a request. Tried both from above $data.



    Does anybody know how to solve this?



    EDIT:



    var_dump of header (curl_setopt($ch, CURLINFO_HEADER_OUT, true);)



        array (size=27)
    'url' => string 'https://openapi.etsy.com/v2/listings/645283994/images' (length=53)
    'content_type' => string 'text/plain;charset=UTF-8' (length=24)
    'http_code' => int 400
    'header_size' => int 895
    'request_size' => int 590
    'filetime' => int -1
    'ssl_verify_result' => int 0
    'redirect_count' => int 0
    'total_time' => float 0.234278
    'namelookup_time' => float 3.9E-5
    'connect_time' => float 0.023493
    'pretransfer_time' => float 0.083739
    'size_upload' => float 105
    'size_download' => float 29
    'speed_download' => float 123
    'speed_upload' => float 448
    'download_content_length' => float 29
    'upload_content_length' => float 105
    'starttransfer_time' => float 0.234254
    'redirect_time' => float 0
    'redirect_url' => string '' (length=0)
    'primary_ip' => string '151.101.13.224' (length=14)
    'certinfo' =>
    array (size=0)
    empty
    'primary_port' => int 443
    'local_ip' => string '192.168.2.73' (length=12)
    'local_port' => int 40466
    'request_header' => string 'POST /v2/listings/645283994/images HTTP/1.1

    Host: openapi.etsy.com

    User-Agent: PHPoAuthLib

    Accept: */*

    Authorization: OAuth oauth_consumer_key="**************************", oauth_nonce="****************************8", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1542272124", oauth_version="1.0", oauth_token="*************", oauth_signature="******************"
    Content-type: multipart/form-data
    Connection: close
    Content-Length: 105









    share|improve this question



























      0












      0








      0








      There are few practically the same questions but no good answer.
      I have to send images to Etsy endpoint.



      Decided to use lusitanian library found on git. It internally uses curl to make POST request.



      Constantly get "The request body is too large" response.



      Code:



      $data = [
      //'@image' => new CURLFile($imagePath, $mime, $imageFilename),
      '@image' => '@'.$imagePath.';type='.$mime,
      ];

      try {
      $response = $etsyService->request(
      $this->uri . '/' . $listingId . '/images',
      'POST',
      $data,
      array(
      'Content-Type'=>'multipart/form-data'
      );
      var_dump($response);die;
      } catch (Exception $e) {
      var_dump($e->getMessage());
      }


      Internally lusitanian uses this:



      curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);


      to make a request. Tried both from above $data.



      Does anybody know how to solve this?



      EDIT:



      var_dump of header (curl_setopt($ch, CURLINFO_HEADER_OUT, true);)



          array (size=27)
      'url' => string 'https://openapi.etsy.com/v2/listings/645283994/images' (length=53)
      'content_type' => string 'text/plain;charset=UTF-8' (length=24)
      'http_code' => int 400
      'header_size' => int 895
      'request_size' => int 590
      'filetime' => int -1
      'ssl_verify_result' => int 0
      'redirect_count' => int 0
      'total_time' => float 0.234278
      'namelookup_time' => float 3.9E-5
      'connect_time' => float 0.023493
      'pretransfer_time' => float 0.083739
      'size_upload' => float 105
      'size_download' => float 29
      'speed_download' => float 123
      'speed_upload' => float 448
      'download_content_length' => float 29
      'upload_content_length' => float 105
      'starttransfer_time' => float 0.234254
      'redirect_time' => float 0
      'redirect_url' => string '' (length=0)
      'primary_ip' => string '151.101.13.224' (length=14)
      'certinfo' =>
      array (size=0)
      empty
      'primary_port' => int 443
      'local_ip' => string '192.168.2.73' (length=12)
      'local_port' => int 40466
      'request_header' => string 'POST /v2/listings/645283994/images HTTP/1.1

      Host: openapi.etsy.com

      User-Agent: PHPoAuthLib

      Accept: */*

      Authorization: OAuth oauth_consumer_key="**************************", oauth_nonce="****************************8", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1542272124", oauth_version="1.0", oauth_token="*************", oauth_signature="******************"
      Content-type: multipart/form-data
      Connection: close
      Content-Length: 105









      share|improve this question
















      There are few practically the same questions but no good answer.
      I have to send images to Etsy endpoint.



      Decided to use lusitanian library found on git. It internally uses curl to make POST request.



      Constantly get "The request body is too large" response.



      Code:



      $data = [
      //'@image' => new CURLFile($imagePath, $mime, $imageFilename),
      '@image' => '@'.$imagePath.';type='.$mime,
      ];

      try {
      $response = $etsyService->request(
      $this->uri . '/' . $listingId . '/images',
      'POST',
      $data,
      array(
      'Content-Type'=>'multipart/form-data'
      );
      var_dump($response);die;
      } catch (Exception $e) {
      var_dump($e->getMessage());
      }


      Internally lusitanian uses this:



      curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);


      to make a request. Tried both from above $data.



      Does anybody know how to solve this?



      EDIT:



      var_dump of header (curl_setopt($ch, CURLINFO_HEADER_OUT, true);)



          array (size=27)
      'url' => string 'https://openapi.etsy.com/v2/listings/645283994/images' (length=53)
      'content_type' => string 'text/plain;charset=UTF-8' (length=24)
      'http_code' => int 400
      'header_size' => int 895
      'request_size' => int 590
      'filetime' => int -1
      'ssl_verify_result' => int 0
      'redirect_count' => int 0
      'total_time' => float 0.234278
      'namelookup_time' => float 3.9E-5
      'connect_time' => float 0.023493
      'pretransfer_time' => float 0.083739
      'size_upload' => float 105
      'size_download' => float 29
      'speed_download' => float 123
      'speed_upload' => float 448
      'download_content_length' => float 29
      'upload_content_length' => float 105
      'starttransfer_time' => float 0.234254
      'redirect_time' => float 0
      'redirect_url' => string '' (length=0)
      'primary_ip' => string '151.101.13.224' (length=14)
      'certinfo' =>
      array (size=0)
      empty
      'primary_port' => int 443
      'local_ip' => string '192.168.2.73' (length=12)
      'local_port' => int 40466
      'request_header' => string 'POST /v2/listings/645283994/images HTTP/1.1

      Host: openapi.etsy.com

      User-Agent: PHPoAuthLib

      Accept: */*

      Authorization: OAuth oauth_consumer_key="**************************", oauth_nonce="****************************8", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1542272124", oauth_version="1.0", oauth_token="*************", oauth_signature="******************"
      Content-type: multipart/form-data
      Connection: close
      Content-Length: 105






      php curl etsy






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 '18 at 14:46







      zeljko miloradovic

















      asked Nov 14 '18 at 15:34









      zeljko miloradoviczeljko miloradovic

      317




      317
























          1 Answer
          1






          active

          oldest

          votes


















          0














          The problem was (as much as I could see) in the lusitanian library.



          In Signature class getSignature method, line 62 stands:



          $signatureData[rawurlencode($key)] = rawurlencode($value);


          From some reason in this $signatureData are also data from the request body. Because image field is here, which is an object rowurlencode() returned null!



          Problem solved (temporary!) with:



          if(strpos($key, 'oauth_') !== false) {
          $signatureData[rawurlencode($key)] = rawurlencode($value);
          }


          And with commented three lines from curlClient class 91 - 93.



          It took me a few days to find out. Mr. President give me the medal :)






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2fstackoverflow.com%2fquestions%2f53303720%2fetsy-file-upload-curl-err-request-body-is-too-large%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














            The problem was (as much as I could see) in the lusitanian library.



            In Signature class getSignature method, line 62 stands:



            $signatureData[rawurlencode($key)] = rawurlencode($value);


            From some reason in this $signatureData are also data from the request body. Because image field is here, which is an object rowurlencode() returned null!



            Problem solved (temporary!) with:



            if(strpos($key, 'oauth_') !== false) {
            $signatureData[rawurlencode($key)] = rawurlencode($value);
            }


            And with commented three lines from curlClient class 91 - 93.



            It took me a few days to find out. Mr. President give me the medal :)






            share|improve this answer




























              0














              The problem was (as much as I could see) in the lusitanian library.



              In Signature class getSignature method, line 62 stands:



              $signatureData[rawurlencode($key)] = rawurlencode($value);


              From some reason in this $signatureData are also data from the request body. Because image field is here, which is an object rowurlencode() returned null!



              Problem solved (temporary!) with:



              if(strpos($key, 'oauth_') !== false) {
              $signatureData[rawurlencode($key)] = rawurlencode($value);
              }


              And with commented three lines from curlClient class 91 - 93.



              It took me a few days to find out. Mr. President give me the medal :)






              share|improve this answer


























                0












                0








                0







                The problem was (as much as I could see) in the lusitanian library.



                In Signature class getSignature method, line 62 stands:



                $signatureData[rawurlencode($key)] = rawurlencode($value);


                From some reason in this $signatureData are also data from the request body. Because image field is here, which is an object rowurlencode() returned null!



                Problem solved (temporary!) with:



                if(strpos($key, 'oauth_') !== false) {
                $signatureData[rawurlencode($key)] = rawurlencode($value);
                }


                And with commented three lines from curlClient class 91 - 93.



                It took me a few days to find out. Mr. President give me the medal :)






                share|improve this answer













                The problem was (as much as I could see) in the lusitanian library.



                In Signature class getSignature method, line 62 stands:



                $signatureData[rawurlencode($key)] = rawurlencode($value);


                From some reason in this $signatureData are also data from the request body. Because image field is here, which is an object rowurlencode() returned null!



                Problem solved (temporary!) with:



                if(strpos($key, 'oauth_') !== false) {
                $signatureData[rawurlencode($key)] = rawurlencode($value);
                }


                And with commented three lines from curlClient class 91 - 93.



                It took me a few days to find out. Mr. President give me the medal :)







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 19 '18 at 15:38









                zeljko miloradoviczeljko miloradovic

                317




                317
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • 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%2fstackoverflow.com%2fquestions%2f53303720%2fetsy-file-upload-curl-err-request-body-is-too-large%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

                    Florida Star v. B. J. F.

                    Danny Elfman

                    Lugert, Oklahoma