Qlik Community

Connectivity & Data Prep

Discussion board where members can learn more about Qlik Sense Data Connectivity.

Announcements
Read about the latest Qlik Community enhancements on the Community News blog!
cancel
Showing results for 
Search instead for 
Did you mean: 
seband_fredes
Contributor II
Contributor II

REST CONNECTOR Access Token desde CORESYSTEM a Qlikview

Hola a todos, espero que se encuentren bien, quisiera consultar lo siguiente:

Tengo una conexión a una API (CORESYSTEMS) desde QlikView, esta necesita un Access Token que caduca cada 5 – 6 hrs, por lo que debe ser renovada:

 

CUSTOM CONNECT TO    "Provider=QvRestConnector.exe;
     url=https://auth.coresuite.com/api/oauth2/v1/token;
     timeout=30;
     method=POST;
     requestBody=grant_type%2client_credentials;
     httpProtocol=1.1;
     isKeepAlive=1;
     bodyEncoding=UTF-8;
     sendExpect100Continue=1;
     autoDetectResponseType=1;
     checkResponseTypeOnTestConnection=1;
     keyGenerationStrategy=0;
     authSchema=anonymous;
     skipServerCertificateValidation=0;
     useCertificate=No;
     certificateStoreLocation=CurrentUser;
     certificateStoreName=My;
     addMissingQueryParametersToFinalRequest=0;
     queryHeaders=Content-Type%2application/x-www-form-urlencoded%1authorization%2Basic *****%%2;
     PaginationType=None;
     allowResponseHeaders=0;
     allowHttpsOnly=0;
     XUserId=****;
     XPassword=****;";

RestConnectorMasterTable2:
SQL SELECT
    "__KEY_root",
        "access_token"
FROM JSON (wrap on) "root" PK "__KEY_root";
 

[token]:
LOAD    [access_token],
        [__KEY_root]
RESIDENT RestConnectorMasterTable2
WHERE NOT IsNull([__KEY_root]);


LET vtoken = Peek('access_token', 0, 'token'); // AQUÍ GUARDO EL TOKEN

Trace $(vtoken);

DROP TABLE RestConnectorMasterTable2;

 

Con este script obtengo el Access Token, ahora lo debo ingresar en el siguiente script que tiene por finalidad extraer la data de la api:

CUSTOM CONNECT TO "Provider=QvRestConnector.exe;

url=https://us.coresuite.com/api/query/v1;

timeout=30;

method=POST;

 

requestBody={%3query%3: %3

SELECT cte.id as id

, cte.lastChanged as lastChanged

, cte.value as Detenido

 

, sc.code as callID

from ServiceCall sc JOIN Activity a ON a.object.objectId%2sc.id

JOIN ChecklistInstance ci ON ci.object.objectId%2a.id

JOIN ChecklistTemplate ct ON ci.template%2ct.id

JOIN ChecklistInstanceElement cte ON cte.checklistInstance%2ci.id

WHERE  cte.lastChanged >%2'2020-01-01T00:00:00Z'

AND cte.title %2 'Equipo Detenido'

AND cte.value %2 'true' %3};

 

httpProtocol=1.1;

isKeepAlive=1;

bodyEncoding=UTF-8;

sendExpect100Continue=1;

autoDetectResponseType=1;

checkResponseTypeOnTestConnection=1;

keyGenerationStrategy=0;

authSchema=anonymous;

skipServerCertificateValidation=0;

useCertificate=No;

certificateStoreLocation=CurrentUser;

certificateStoreName=My;

queryParameters=account%2****%1company%2****%1clientIdentifier%2COR_NON_NONE%1dtos%2ServiceCall.21%%1ChecklistInstanceElement.12%%1ChecklistInstance.14%%1ChecklistTemplate.18%%1Activity.21;

addMissingQueryParametersToFinalRequest=0;

queryHeaders=Content-Type%2application/json%1X-client-ID%****%1X-Client-Version%21.0%1Authorization%2Bearer Access_token;

PaginationType=NextPage;

NextPageField=page;

IsNextPageFieldHeader=0;

NextPageFieldValue=1;

NextPageSizeFieldName=pageSize;

IsNextPageSizeFieldHeader=0;

NextPageSizeFieldValue=50;

NextPageTotalPath=root/lastPage;

IsNextPageTotalPathHeader=0;

NextPageDataPath=root/data;

allowResponseHeaders=0;

allowHttpsOnly=0;

XUserId=****;

XPassword=****;";


RestConnectorMasterTable:
SQL SELECT
    "__KEY_root",
    (SELECT
        "callID",
            "detenido",
            "lastChanged",
            "id",
        "__KEY_data",
        "__FK_data"
    FROM "data" PK "__KEY_data" FK "__FK_data")
FROM JSON (wrap on) "root" PK "__KEY_root";

 

[data]:
LOAD    [callID]
  
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_data]);

DROP TABLE RestConnectorMasterTable;

 

En la actualidad el Access token lo tengo que obtener y pegar de manera manual desde POSTMAN a Qlikview. ¿De qué manera puedo ingresar el Access token ya guardado en una variable al script que extrae la data de la API?

 

De antemano muchas gracias por la ayuda.

0 Replies