ninox API query Endpoint URI Encoding
Posted: Tue Jun 16, 2020 11:25 am
I try to make use of the query endpoint of the ninox API.https://ninox.com/de/manual/ninox-api/rest-api
The response I get is "API CALL Failed: {"message":"Query not provided"} Status Code: 400".
In the Docs they say ".....The query parameter must be escaped with all URI component encoding methods...." but how can I do that in Enfocus Switch".
Can somebody help?
Thanks in Advance
Code: Select all
function verknuepfen(){
var url = "https://api.ninoxdb.de/v1/teams/uvG2423sCarz7twsCfQ/databases/e5341uvc8plac1/query";
var key = "myToken";
var json = new ByteArray("{\"Query\":\"1 + 2\"}", "UTF-8");
var theHTTP = new HTTP( HTTP.SSL );
theHTTP.authScheme = HTTP.OauthAuth;
theHTTP.authorization = "Bearer "+key;
theHTTP.url = url;
theHTTP.setPostData( json,"application/json" );
theHTTP.post();
while( !theHTTP.waitForFinished( 3 ) )
{
job.log( 1, "API CALL IN PROGRESS!" );
}
if( theHTTP.finishedStatus == HTTP.Ok && theHTTP.statusCode == 200 )
{
job.log(1,"API CALL successfull RESPONSE: "+theHTTP.getServerResponse().toString( "UTF-8" ));
}
else
{
job.log(1,"API CALL Failed: "+theHTTP.getServerResponse().toString( "UTF-8" )+ " Status Code: "+theHTTP.statusCode.toString( "UTF-8" ))
}
}
verknuepfen()
In the Docs they say ".....The query parameter must be escaped with all URI component encoding methods...." but how can I do that in Enfocus Switch".
Can somebody help?
Thanks in Advance