# Calling leadApi returns The response returned is in an unexpected format

**URL:** <https://forum.mautic.org/t/calling-leadapi-returns-the-response-returned-is-in-an-unexpected-format/5726>\
**Category:** Product Support\
**Created:** [March 25, 2016, 6:22pm UTC](https://forum.mautic.org/t/calling-leadapi-returns-the-response-returned-is-in-an-unexpected-format/5726 "2016-03-25T18:22:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tasselhof](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@tasselhof](https://forum.mautic.org/u/tasselhof)\
**Post date:** [March 25, 2016, 6:22pm UTC](https://forum.mautic.org/t/calling-leadapi-returns-the-response-returned-is-in-an-unexpected-format/5726/1 "2016-03-25T18:22:35Z")

</div>

I am trying to create new lead but any calling ends in error 500: The response returned is in an unexpected format  
  
  
  
I am doing this:

Code:

$leadApi = MauticMauticApi::getContext( "leads", $auth, $mauticBaseUrl ); 

$fields = $leadApi-\>getFieldList();

  
and the above call ends in already mentioned error. This is how the **leadApi** object looks if i call

Code:

print\_r

on it:  

Code:

MauticApiLeads Object ( [endpoint:protected] =\> leads [baseUrl:protected] =\> http://mautic.mywii.cz [auth:MauticApiApi:private] =\> MauticAuthOAuth Object ( [\_client\_id:protected] =\> 4sc07f856ayowwg4goksw8swgg44cow0kocgwogoww0oc4w0gc [\_client\_secret:protected] =\> 1zxgxulnl4pw0cs4o0kwookgowgwwkk48os4w0ws0wo4c0oo40 [\_callback:protected] =\> http://mywii.cz/?edd-listener=mautic [\_access\_token:protected] =\> 5088ugpt5egwcwsckog4sw8ockk0k40k00cwg0ok444848084g [\_access\_token\_secret:protected] =\> 1e8aix94n2jo88scsoooow880sckg4sso4wgkkwwwc8wss8wwo [\_expires:protected] =\> [\_refresh\_token:protected] =\> [\_token\_type:protected] =\> [\_access\_token\_updated:protected] =\> [\_redirect\_type:protected] =\> code [\_scope:protected] =\> Array ( )

```
        [_authorize_url:protected] => http://mautic.mywii.cz/oauth/v1/authorize
        [_access_token_url:protected] => http://mautic.mywii.cz/oauth/v1/access_token
        [_request_token_url:protected] => http://mautic.mywii.cz/oauth/v1/request_token
        [_debug:protected] => 
    )

[logger:MauticApiApi:private] => PsrLogNullLogger Object
    (
    )

```

)

  
Is there some obvious error I done? What should I do next in order to debug this?

---

<div class="post-metadata">

**Author:** ![alfonso](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@alfonso](https://forum.mautic.org/u/alfonso)\
**Post date:** [March 26, 2016, 7:55pm UTC](https://forum.mautic.org/t/calling-leadapi-returns-the-response-returned-is-in-an-unexpected-format/5726/2 "2016-03-26T19:55:19Z")

</div>

Same message here…

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [March 30, 2016, 8:04am UTC](https://forum.mautic.org/t/calling-leadapi-returns-the-response-returned-is-in-an-unexpected-format/5726/3 "2016-03-30T08:04:22Z")

</div>

I tested it with the API tester and it returned the array for me:  
 ![](https://docs.google.com/uc?id=0B0VKZ9KdWYKnTTNtdmlOOEFwQ0k)

Other API calls work?

---

<div class="post-metadata">

**Author:** ![tasselhof](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@tasselhof](https://forum.mautic.org/u/tasselhof)\
**Post date:** [March 30, 2016, 8:15am UTC](https://forum.mautic.org/t/calling-leadapi-returns-the-response-returned-is-in-an-unexpected-format/5726/4 "2016-03-30T08:15:18Z")

</div>

[quote=9184:@escopecz]I tested it with the API tester and it returned the array for me:  
 ![](https://docs.google.com/uc?id=0B0VKZ9KdWYKnTTNtdmlOOEFwQ0k)

Other API calls work?[/quote]

This was actually the first time I tried to use Apitester 🙂 but, surprisingly, I cannot even use apitester because I am getting this error:

```auto
Warning: require(): Unable to access /vendor/autoload.php in /apitester/index.php on line 5
```

The line in apitester/index.php says:

```auto
require dirname( __DIR__ ).'/vendor/autoload.php';
```

Looking at original [Github api library](https://github.com/mautic/api-library) I cannot see anywhere the “vendor” subfolder anywhere…

Should I raise github issue for that or is this note enough?

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [March 30, 2016, 8:17am UTC](https://forum.mautic.org/t/calling-leadapi-returns-the-response-returned-is-in-an-unexpected-format/5726/5 "2016-03-30T08:17:22Z")

</div>

I see. You need to run `composer install` to install the vendor libraries. I can see it’s not in the readme…

---

<div class="post-metadata">

**Author:** ![tasselhof](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@tasselhof](https://forum.mautic.org/u/tasselhof)\
**Post date:** [March 25, 2016, 6:22pm UTC](https://forum.mautic.org/t/calling-leadapi-returns-the-response-returned-is-in-an-unexpected-format/5726/6 "2016-03-25T18:22:36Z")

</div>

I am trying to create new lead but any calling ends in error 500: The response returned is in an unexpected format

I am doing this:

```auto
$leadApi = MauticMauticApi::getContext(
    "leads",
    $auth,
    $mauticBaseUrl 
);  

$fields = $leadApi->getFieldList();
```

and the above call ends in already mentioned error. This is how the leadApi object looks if i call `print_r` on it:

```auto
MauticApiLeads Object
(
    [endpoint:protected] => leads
    [baseUrl:protected] => http://mautic.mywii.cz
    [auth:MauticApiApi:private] => MauticAuthOAuth Object
        (
            [_client_id:protected] => 4sc07f856ayowwg4goksw8swgg44cow0kocgwogoww0oc4w0gc
            [_client_secret:protected] => 1zxgxulnl4pw0cs4o0kwookgowgwwkk48os4w0ws0wo4c0oo40
            [_callback:protected] => http://mywii.cz/?edd-listener=mautic
            [_access_token:protected] => 5088ugpt5egwcwsckog4sw8ockk0k40k00cwg0ok444848084g
            [_access_token_secret:protected] => 1e8aix94n2jo88scsoooow880sckg4sso4wgkkwwwc8wss8wwo
            [_expires:protected] => 
            [_refresh_token:protected] => 
            [_token_type:protected] => 
            [_access_token_updated:protected] => 
            [_redirect_type:protected] => code
            [_scope:protected] => Array
                (
                )

            [_authorize_url:protected] => http://mautic.mywii.cz/oauth/v1/authorize
            [_access_token_url:protected] => http://mautic.mywii.cz/oauth/v1/access_token
            [_request_token_url:protected] => http://mautic.mywii.cz/oauth/v1/request_token
            [_debug:protected] => 
        )

    [logger:MauticApiApi:private] => PsrLogNullLogger Object
        (
        )

)
```

Is there some obvious error I done? What should I do next in order to debug this?
