Hello!
I got my REST API working. Now i want to GET the results and insert it into a table that i have created.
Is there anyone that have a working example of this?
I am using this:
$method = "GET";
$url = "url to the suppiler API";
// replace variables in the URL
$url = RunnerContext::PrepareRest( $url );
// do the API request
$response = $dataSource->getConnection()->requestJson( $url, $method );
if( $response === false ) {
// something went wrong
$dataSource->setError( $dataSource->getConnection()->lastError() );
return false;
}
// convert API result into recordset
$rs = $dataSource->resultFromJson( $response, true );
if( !$rs ) {
return false;
}
// apply search and filter parameters. Comment out this line if filtering is done by REST API provider
$rs = $dataSource->filterResult( $rs, $command->filter );
// apply order parameters
$dataSource->reorderResult( $command, $rs );
// apply pagination
$rs->seekRecord( $command->startRecord );
return $rs;