title: wp_remote_post response body is protected
body: <p>I have made an API call with <code>wp_remote_post</code> and tried to retrieve the body with <code>wp_remote_retrieve_body</code>. But the response only showing headers and the body is protected.</p>
  
  <p>below code, I have used to make an API call.</p>
  
  <pre><code>$args = array(
                  'LocationId' =&gt; $loc_id,
                  'AppId' =&gt; $app_id
                 );
      $response = wp_remote_post( 'https://www.apiurl.com?APIKEY='."$api_key".'', $args );
  
  $responceData = json_decode(wp_remote_retrieve_body( $response ), TRUE );
  print_r($response);
  </code></pre>
  
  <p>and the printed response (just starting piece of data) is :</p>
  
  <blockquote>
    <p>Array ( [headers] => Requests_Utility_CaseInsensitiveDictionary Object ( [data:protected]</p>
  </blockquote>
  
  <p>I am developing the wordpress plugin in localhost. How to solve this error. </p>
  
  <p>Full Response :</p>
  
  <pre><code>Array ( [headers] =&gt; Requests_Utility_CaseInsensitiveDictionary Object ( [data:protected] =&gt; Array ( [cache-control] =&gt; no-cache, no-store [pragma] =&gt; no-cache [content-type] =&gt; application/json; charset=utf-8 [expires] =&gt; -1 [server] =&gt; Microsoft-IIS/10.0 [access-control-allow-origin] =&gt; * [x-aspnet-version] =&gt; 4.0.30319 [x-powered-by] =&gt; ASP.NET [date] =&gt; Fri, 13 Jul 2018 06:24:16 GMT [content-length] =&gt; 1858 ) ) [body] =&gt; {"Already10Questions":{"Count":1,"ResponseErrors":[{"Already10Questions":null,"AlreadyEmailErrorMessage":null,"AuthorizationError":null,"CaseNo":"[180712-23:24:16]_3D94D663C0DB","ErrorMessage":null,"SuccessMsg":null,"UserRegisterSuccessMsg":null}]},"AlreadyEmailErrorMessages":{"Count":1,"ResponseErrors":[{"Already10Questions":null,"AlreadyEmailErrorMessage":null,"AuthorizationError":null,"CaseNo":"[180712-23:24:16]_3D94D663C0DB","ErrorMessage":null,"SuccessMsg":null,"UserRegisterSuccessMsg":null}]},"AuthorizationError":{"Count":1,"ResponseErrors":[{"Already10Questions":null,"AlreadyEmailErrorMessage":null,"AuthorizationError":null,"CaseNo":"[180712-23:24:16]_3D94D663C0DB","ErrorMessage":null,"SuccessMsg":null,"UserRegisterSuccessMsg":null}]},"ErrorMessages":{"Count":1,"ResponseErrors":[{"Already10Questions":null,"AlreadyEmailErrorMessage":null,"AuthorizationError":null,"CaseNo":"[180712-23:24:16]_3D94D663C0DB","ErrorMessage":null,"SuccessMsg":null,"UserRegisterSuccessMsg":null}]},"ExistPhoneNumber":{"Count":1,"ResponseErrors":[{"Already10Questions":null,"AlreadyEmailErrorMessage":null,"AuthorizationError":null,"CaseNo":"[180712-23:24:16]_3D94D663C0DB","ErrorMessage":null,"SuccessMsg":null,"UserRegisterSuccessMsg":null}]},"SuccessMsg":{"Count":1,"ResponseErrors":[{"Already10Questions":null,"AlreadyEmailErrorMessage":null,"AuthorizationError":null,"CaseNo":"[180712-23:24:16]_3D94D663C0DB","ErrorMessage":null,"SuccessMsg":null,"UserRegisterSuccessMsg":null}]},"UserRegisterSuccessmessages":{"Count":1,"ResponseErrors":[{"Already10Questions":null,"AlreadyEmailErrorMessage":null,"AuthorizationError":null,"CaseNo":"[180712-23:24:16]_3D94D663C0DB","ErrorMessage":null,"SuccessMsg":null,"UserRegisterSuccessMsg":null}]},"CheckUserLocationAccessByLocationIdList":null,"ItemsCount":0,"RestaurantTotalCountByFilterList":null,"appDetails":null} 
  </code></pre>
  
  <p><strong>UPDATE: Problem is solved with the below code. In my understanding, the problem is with sending arguments to the API in a wrong way.</strong>  <strong>Thanks For Helping <a href="https://stackoverflow.com/users/9217760/sally-cj">Sally Cj</a></strong></p>
  
  <pre><code>$postData = array(
      'LocationId' =&gt; $loc_id,
      'AppId' =&gt; $app_id,
  );
  $context = array(
          'method' =&gt; 'POST',
          'headers' =&gt; "Authorization:\r\n".
              "Content-Type: application/json\r\n",
          'httpversion' =&gt; '1.0',
          'redirection' =&gt; 5,
          'timeout' =&gt; 60,
          'blocking' =&gt; true,
          'body' =&gt; json_encode($postData)
      );
              $response = wp_remote_post( 'apiurl.com?APIKEY='."$api_key".'', $context);
              $currency = wp_remote_post( 'apiurl.com?APIKEY='."$api_key".'', $context);
  
  if ( is_wp_error( $response ) ) {
     $error_message = $response-&gt;get_error_message();
     echo "Something went wrong: $error_message";
  } else {
      $responceData = json_decode(wp_remote_retrieve_body($response), true);
      $currencyData = json_decode(wp_remote_retrieve_body($currency), true);
  </code></pre>