Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
IPBWI.com Matthias Reuter Posted September 27, 2016 Posted September 27, 2016 When using the REST API, a GET request is quite easy as long as .htaccess based SEO URLs are activated, this URL string would work: /api/forums/topics?sortBy=date&sortDir=desc But with deactivated SEO friendly URLs, this string would work: /api/index.php?/forums/topics but this one not: /api/index.php?/forums/topics?sortBy=date&sortDir=desc So how should I add the extra GET variables without generating an 3S290/4 INVALID_CONTROLLER error?
CodingJungle Posted September 27, 2016 Posted September 27, 2016 have you tried: /api/index.php?/forums/topics/&sortBy=date&sortDir=desc
Ryan Ashbrook Posted September 27, 2016 Posted September 27, 2016 /api/index.php?/forums/topics&sortBy=date&sortDir=desc
newbie LAC Posted September 28, 2016 Posted September 28, 2016 13 hours ago, CodingJungle said: have you tried: /api/index.php?/forums/topics/&sortBy=date&sortDir=desc In this case you get an error errorCode: "1F294/1", errorMessage: "INVALID_ID" 12 hours ago, Ryan Ashbrook said: /api/index.php?/forums/topics&sortBy=date&sortDir=desc In this case you get an error errorCode: "3S290/4", errorMessage: "INVALID_CONTROLLER"
HeadStand Posted September 29, 2016 Posted September 29, 2016 What about /api/index.php?/forums/topics?&sortBy=date&sortDir=desc
CodingJungle Posted September 29, 2016 Posted September 29, 2016 5 minutes ago, HeadStand said: What about /api/index.php?/forums/topics?&sortBy=date&sortDir=desc according to this i was close, ryan got it right i had an extra forward slash
newbie LAC Posted September 29, 2016 Posted September 29, 2016 1 hour ago, CodingJungle said: ryan got it right Try him example and you get an error errorCode: "3S290/4", errorMessage: "INVALID_CONTROLLER" system/Dispatcher/Api.php if ( \IPS\Settings::i()->use_friendly_urls and \IPS\Settings::i()->htaccess_mod_rewrite ) { /* We are using Mod Rewrite URL's, so look in the path */ $path = mb_substr( \IPS\Request::i()->url()->data[ \IPS\Http\Url::COMPONENT_PATH ], mb_strpos( \IPS\Request::i()->url()->data[ \IPS\Http\Url::COMPONENT_PATH ], '/api/' ) + 5 ); } else { /* Otherwise we are not, so we need the query string instead, which is actually easier */ $path = \IPS\Request::i()->url()->data[ \IPS\Http\Url::COMPONENT_QUERY ]; } $pathBits = array_filter( explode( '/', $path ) ); $pathBits in this case is Array ( [1] => forums [2] => topics&sortBy=date&sortDir=desc ) go ahead /* Work out the app and controller. Both can only be alphanumeric - prevents include injections */ $app = array_shift( $pathBits ); if ( !preg_match( '/^[a-z0-9]+$/', $app ) ) { throw new \IPS\Api\Exception( 'INVALID_APP', '3S290/3', 400 ); } $controller = array_shift( $pathBits ); if ( !preg_match( '/^[a-z0-9]+$/', $controller ) ) { throw new \IPS\Api\Exception( 'INVALID_CONTROLLER', '3S290/4', 400 ); } $controller is topics&sortBy=date&sortDir=desc
HeadStand Posted September 29, 2016 Posted September 29, 2016 7 hours ago, newbie LAC said: Try him example and you get an error errorCode: "3S290/4", errorMessage: "INVALID_CONTROLLER" system/Dispatcher/Api.php if ( \IPS\Settings::i()->use_friendly_urls and \IPS\Settings::i()->htaccess_mod_rewrite ) { /* We are using Mod Rewrite URL's, so look in the path */ $path = mb_substr( \IPS\Request::i()->url()->data[ \IPS\Http\Url::COMPONENT_PATH ], mb_strpos( \IPS\Request::i()->url()->data[ \IPS\Http\Url::COMPONENT_PATH ], '/api/' ) + 5 ); } else { /* Otherwise we are not, so we need the query string instead, which is actually easier */ $path = \IPS\Request::i()->url()->data[ \IPS\Http\Url::COMPONENT_QUERY ]; } $pathBits = array_filter( explode( '/', $path ) ); $pathBits in this case is Array ( [1] => forums [2] => topics&sortBy=date&sortDir=desc ) go ahead /* Work out the app and controller. Both can only be alphanumeric - prevents include injections */ $app = array_shift( $pathBits ); if ( !preg_match( '/^[a-z0-9]+$/', $app ) ) { throw new \IPS\Api\Exception( 'INVALID_APP', '3S290/3', 400 ); } $controller = array_shift( $pathBits ); if ( !preg_match( '/^[a-z0-9]+$/', $controller ) ) { throw new \IPS\Api\Exception( 'INVALID_CONTROLLER', '3S290/4', 400 ); } $controller is topics&sortBy=date&sortDir=desc Did you try my suggestion?
newbie LAC Posted September 30, 2016 Posted September 30, 2016 16 hours ago, HeadStand said: Did you try my suggestion? errorCode: "3S290/4", errorMessage: "INVALID_CONTROLLER"
bfarber Posted October 3, 2016 Posted October 3, 2016 Ryan's suggestion is correct, however a bug exists in the current release that results in the INVALID_CONTROLLER error that you are seeing. We apologize for this issue, and a patch for the issue will be available in 4.1.16.
IPBWI.com Matthias Reuter Posted October 5, 2016 Author Posted October 5, 2016 was out for a week but glad to see @newbie LAC invested time for testing I've had the same controller error, but it's great to see this bug is going to be fixed
Recommended Posts
Archived
This topic is now archived and is closed to further replies.