This topic is locked

REST API to DB

6/6/2020 6:17:36 PM
PHPRunner General questions
R
RogerN author

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;
fhumanes 6/7/2020

Hello:
I made this example https://asprunner.com/forums/topic/27340-phprunner-app-client-restful-api/
In it you can see how I collect the data with the PHPRunner interface and how I read and load it in tables, in the Database.
Cheers,

fernando