XF 2.2 use api, routing problem

Robert9

Well-known member
My addon is able to call

$url = "https://www.domain.com/api/threads/1/";

The route for api thread is:

<route route_type="api" route_prefix="threads" sub_name="-" format=":+int&lt;thread_id&gt;/" controller="XF:Thread"/>


Now i try the same for my table league

$url = "https://www.domain.com/api/leagues/1/";

<route route_type="api" route_prefix="leagues" sub_name="-" format=":+int&lt;country_id&gt;/" controller="Lala:League"/>


My Fetch_class looks like and works with the first $url $url = "https://www.domain.com/api/threads/1/";

Code:
        try {
            $client = \XF::app()->http()->client();
            $response = $client->request('GET', $url,

                [
                    'debug' => false,

                    'headers' =>
                        [
                            'XF-Api-Key' => $key,
                            'XF-Api-User' => $userId,
                            //'Content-Type' => 'application/json',
                            'Content-Type: application/x-www-form-urlencoded',
                        ],
                ]
            );
        }

but it doesnt work with the second url $url = "https://www.domain.com/api/leagues/1/";


Code:
XF\Mvc\Reply\Error Object
(
    [errors:protected] => Array
        (
            [0] => Error 404 - Not Found
        )

    [responseCode:protected] => 200
...
)

XF has
/api/thread.php

I have
/api/league.php

And now i have no more ideas, what the problem could be. :(
 
Last edited:
Back
Top Bottom