Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted September 27, 20168 yr 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?
September 28, 20168 yr 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"
September 29, 20168 yr 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
September 29, 20168 yr 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
September 29, 20168 yr 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?
September 30, 20168 yr 16 hours ago, HeadStand said: Did you try my suggestion? errorCode: "3S290/4", errorMessage: "INVALID_CONTROLLER"
October 3, 20168 yr 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.
October 5, 20168 yr Author 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
Archived
This topic is now archived and is closed to further replies.