title: Guzzle - Get Raw JSON Response
body: <p>I've been trying to get this working all day so this is my last resort.</p>
  
  <p>I am trying to call an api using guzzle, and this drupal_symfony_inject module:
  <a href="https://github.com/Capgemini/drupal_symfony_inject" rel="nofollow">https://github.com/Capgemini/drupal_symfony_inject</a></p>
  
  <p>I have the following config in hook_symfony_yaml_config_params():</p>
  
  <pre><code>// Assets client.
  $assets_resources_file = $resources_folder . '/moderation.json';
  $param_array['bubl_api_assets_service_client.service.description'] = $assets_resources_file;
  $param_array['bubl_api_assets_client.class'] = 'BUBL\Clients\Assets\Client';
  </code></pre>
  
  <p>And this in my service definition:</p>
  
  <pre><code>{
    "name": "BUBL moderation client",
    "apiVersion": "v1",
    "description": "BUBL moderation REST API client",
    "operations": {
      "getAllBubls": {
        "httpMethod": "GET",
        "uri": "/su/bubls",
        "responseModel": "getJSONResponse",
        "parameters": {
          "before": {
            "location": "uri",
            "type": "integer",
            "required": false
          },
          "after": {
            "location": "uri",
            "type": "integer",
            "required": false
          },
          "max": {
            "location": "uri",
            "type": "integer",
            "required": false
          }
        }
      }
    },
    "models": {
      "getJSONResponse": {
        "type": "object",
        "additionalProperties": {
          "location": "json"
        }
      },
      "getHTMLResponse": {
        "type": "object",
        "properties": {
          "html": {
            "location": "body",
            "type": "string"
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>I have a client with the operations simply returning the response from guzzle, for example:</p>
  
  <pre><code>public function getAllBubls($before = NULL, $after = NULL) {
      $response = $this-&gt;client-&gt;sendRequest('getAllBubls', ['before' =&gt; $before, 'after' =&gt; $after]);
      return $response;
    }
  </code></pre>
  
  <p>And when using it it works absolutely fine, like so:</p>
  
  <pre><code>global $_drupal_symfony_di_container;
      /** @var BUBL\Clients\Moderation\Client $client */
      $client = $_drupal_symfony_di_container-&gt;get('bubl_api_moderation_client');
      if (is_callable(array($client, $service_name))) {
        $response = $client-&gt;{$service_name}();
        return $data_source = $response['bubls'];
      }
  </code></pre>
  
  <p>Now, my problem is that the response is ran through json_decode before I get hold of it, and giving me an array, which is causing me all kinds of problems with the migrate module. I know that it is because of the 
  responseModel set at </p>
  
  <pre><code>"responseModel": "getJSONResponse",
  </code></pre>
  
  <p>However, I can't find a way to simply request a raw response. I have tried (as was alluded to in the documentation), removing the responseModal altogether and adding in:</p>
  
  <pre><code>"responseType": "primitive",
  </code></pre>
  
  <p>and (separately I mean)</p>
  
  <pre><code>"responseModel": "getHTMLResponse",
  </code></pre>
  
  <p>But unfortunately I wouldn't receive any data back with either - just an empty array. I just can't seem to find a way to ignore all of the parsing and just get the response back in JSON? Is it possible?
  I've also tried to create another Model to use, but the types are either array or object, and the rest of the properties are really confusing to me in the documentation, so nothing I've tried is helping. It doesn't seem like it shouldn't go through a Model or Response Class at all, and that there is some way to bypass it perhaps ("primitive" would make sense to me, but alas not).</p>
  
  <p>BTW I'm new to guzzle, and I know this seems a bit over engineered for this one call, but it is important for elsewhere, it's in place and I would like to get my head round it if it's possible to use it.</p>
  
  <p>Thanks.</p>