This topic is locked

REST API question

10/12/2023 12:47:44 PM
PHPRunner General questions
Grdimitris author

I have created a list using OAUTH 2.0 REST API. The returned JSON contains data for multiple tables.
Does anyone know how I can call the 'Rest view single' from a button in the 'Rest view List' so that I can write the data from this JSON to a local database for all the tables it contains?

Grdimitris author 10/12/2023

I found it. I`m getting old and internet searching is geting slow.
In manual there is a section REST API Connections id Programming topics. I waw looking in Using PHPRunner section.
$rconn = getRESTConn("my_api"); //is the connection to my_api that i create in rest api connections
$method = "GET";
$url="" // the url with parameters for single request
$url = RunnerContext::PrepareRest( $url );
$request = new HttpRequest( $url, $method );
// The headers
$value = RunnerContext::PrepareRest( 'application/json', false );
if( $value != '' ) {
$request->headers[ 'accept' ] = $value;
$value = RunnerContext::PrepareRest( 'application/json;charset=utf-8', false );
if( $value != '' ) {
$request->headers[ 'Content-Type' ] = $value;
// The response as JSON string
$response = $rconn->requestWithAuth( $request );
and after that i can make everything i need to to.