Sending a CURL command
I know this is a bit obscure but I thought it would be pretty straightforward. The curl command I need to execute is
[my_user_name]:[my_password] -H "API-TOKEN: [api_token]" -H "API-VERSION: 0.1" https://domainOfInterest.com/api"
Given my very little curl experience, I came up with something along the lines of:
private var loader : HTTPURLLoader;
private var END_POINT : String = "[myDomainOfInterest]";
private var user : String = "[userName]";
private var password : String = "[myPassword]";
private var token: String = "[myToken";
private function loadURL() : void {
var request : URLRequest = new URLRequest();
request.url = END_POINT;
var variables:URLVariables = new URLVariables();
variables.user = userName;
variables.password = myPassword;
var myToken : URLRequestHeader = new URLRequestHeader( "API-TOKEN", token );
request.requestHeaders.push( myToken );
var APIVersion : URLRequestHeader = new URLRequestHeader( "API-VERSION", "0.1" );
request.requestHeaders.push( APIVersion );
request.data = variables;
try {
loader.load( request );
} catch ( error : SecurityError ) {
Logger.error( "A SecurityError has occurred." );
}
}
I am not receiving any bad info (like unauthorized, which I was for awhile) but the data coming back is empty. Is the general form of what I'm trying to do correct?
