How to easy API Call

Post Reply
bkromer
Newbie
Posts: 4
Joined: Thu Jul 11, 2019 10:41 am

How to easy API Call

Post by bkromer » Wed Oct 09, 2019 3:13 pm

I want to do a GET http request with a Bearer token:

Code: Select all

function jobArrived( s : Switch, job : Job )
{
	var theHTTP = new HTTP( HTTP.SSL );
	theHTTP.authScheme = HTTP.OauthAuth;
	theHTTP.authorization = "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";	
	theHTTP.url = "https://app.keyline-mis.com/api/v2/sales/orders";
	theHTTP.get();
	
	 while( !theHTTP.waitForFinished( 3 ) )
  {
       job.log( 1, "API CALL IN PROGRESS!" );
  } 
	
	if( theHTTP.finishedStatus == HTTP.Ok && theHTTP.statusCode == 200 )
  {
		
       
		job.log(1,"RESPONSE: ",theHTTP.getServerResponse().toString( "UTF-8" ));
  }
	
	
}
In messages i get: "09.10.19 15:10,Debug,Control,,,,,HTTP GET request error: HTTP protocol error. 406 Not Acceptable." and "09.10.19 15:10,Info,Scripter control,Test Flow,Script Element,,TDB_Inapa_Clear.pdf,Script evaluation message: End jobArrived entry point with the test fixture"

Docs: https://keyline-mis.de/docs/api#

How can i make this work?
lg
Ben

Post Reply